Capistrano 3,Rails 4,数据库配置未指定适配器

编程入门 行业动态 更新时间:2024-10-24 22:29:06
本文介绍了Capistrano 3,Rails 4,数据库配置未指定适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我开始

上限生产部署

cap production deploy

它像这样失败:

DEBUG [4ee8fa7a] Command: cd /home/deploy/myapp/releases/releases/20131025212110 && (RVM_BIN_PATH=~/.rvm/bin RAILS_ENV= ~/.rvm/bin/myapp_rake assets:precompile ) DEBUG [4ee8fa7a] rake aborted! DEBUG [4ee8fa7a] database configuration does not specify adapter

您可以看到 RAILS_ENV = 实际上是空的,我想知道为什么会这样吗?我认为这是我没有数据库配置的后一个错误的原因。 deploy.rb文件如下:

You can see that "RAILS_ENV=" is actually empty and I'm wondering why that might be happening? I assume that this is the reason for the latter error that I don't have a database configuration. The deploy.rb file is below:

set :application, 'myapp' set :repo_url, 'git@github:developer/myapp.git' set :branch, :master set :deploy_to, '/home/deploy/myapp/releases' set :scm, :git set :devpath, "/home/deploy/myapp_development" set :user, "deploy" set :use_sudo, false set :default_env, { rvm_bin_path: '~/.rvm/bin' } set :keep_releases, 5 namespace :deploy do desc 'Restart application' task :restart do on roles(:app), in: :sequence, wait: 5 do # Your restart mechanism here, for example: within release_path do execute " bundle exec thin restart -O -C config/thin/production.yml" end end end after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do within release_path do end end end after :finishing, 'deploy:cleanup' end

Database.yml:

Database.yml:

production: adapter: mysql2 encoding: utf8 database: myapp_production pool: 5 username: user password: pass host: localhost development: adapter: mysql2 encoding: utf8 database: myapp_development pool: 5 username: user password: pass host: localhost

如果我添加

set :rails_env, "production"

到我的deploy.rb,但这对我来说似乎是硬编码,我敢肯定有更好的解决方案。 / p>

to my deploy.rb, but this looks like hardcoding to me and I'm sure there's a nicer solution.

推荐答案

编辑:每此提取请求,现已在 capistrano-rails 的 1.1.0 版本中修复

Per this pull request, it's now fixed in version 1.1.0 of capistrano-rails.

每个此Github问题,另一个解决方法是编辑您的 Capfile 。注释掉这两行

Per this Github issue, another fix is to edit your Capfile. Comment out these two lines

#require 'capistrano/rails/assets' #require 'capistrano/rails/migrations'

并将此行放入

require 'capistrano/rails'

这将正确设置 RAILS_ENV 变量。

更多推荐

Capistrano 3,Rails 4,数据库配置未指定适配器

本文发布于:2023-10-16 10:25:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497302.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适配器   数据库   Capistrano   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!