gpt4 book ai didi

ruby-on-rails - Capistrano 3,Rails 4,数据库配置未指定适配器

转载 作者:行者123 更新时间:2023-12-03 13:41:40 24 4
gpt4 key购买 nike

当我开始


上限生产部署


它失败是这样的:

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文件如下:

set :application, 'myapp'
set :repo_url, 'git@github.com: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:

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,但这对我来说似乎是硬编码,并且我确定有更好的解决方案。

最佳答案

编辑:根据this pull request,现在已在1.1.0的版本capistrano-rails中修复。

根据this Github issue,另一种解决方法是编辑您的Capfile。注释掉这两行

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


并把这行

需要“ capistrano / rails”


这将正确设置您的RAILS_ENV变量。

关于ruby-on-rails - Capistrano 3,Rails 4,数据库配置未指定适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19599986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com