我是Ruby-on-Rails的新手,并且尝试使用Capistrano部署我的rails应用程序。 当我使用cap production deploy
,它失败并显示以下错误:
rake stdout: rake aborted!
NoMethodError: undefined method `[]' for false:FalseClass
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/mongoid-4.0.2/lib/mongoid/config/environment.rb:40:in `load_yaml'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/mongoid-4.0.2/lib/mongoid/config.rb:83:in `load!'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/mongoid-4.0.2/lib/mongoid.rb:99:in `load!'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/mongoid-4.0.2/lib/mongoid/railtie.rb:62:in `block in <class:Railtie>'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/initializable.rb:30:in `instance_exec'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/initializable.rb:30:in `run'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/initializable.rb:54:in `run_initializers'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/application.rb:352:in `initialize!'
/Users/yihe/code/server/releases/20150817105558/config/environment.rb:5:in `<top (required)>'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/application.rb:328:in `require'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/application.rb:328:in `require_environment!'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/Users/yihe/code/server/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
Tasks: TOP => environment
这是我的deploy.rb
lock '3.4.0'
set :application, 'redhouse'
set :deploy_to, "/Users/yihe/code/server"
set :deploy_user, 'yihe'
set :scm, :git
set :repo_url, '[email protected]:alexZhou/redhorse.git'
set :format, :pretty
set :pty, true
# rvm
# set :rvm_type, :system
set :rvm_ruby_version, '2.2.2'
set :rvm_roles, [:app, :web, :db]
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml', 'config/mongoid.yml')
set :keep_releases, 5
这是我的Mongoid配置:
development:
sessions:
default:
database: redhorse_development
hosts:
- localhost:27017
options:
options:
test:
sessions:
default:
database: redhorse_test
hosts:
- localhost:27017
options:
read: primary
max_retries: 1
retry_interval: 0
为什么我看到这个问题? 我该如何解决?
堆栈跟踪表明它尝试在失败时尝试在服务器上加载config/mongoid.yml
。 您已设置它以符号链接该文件,但是由于加载它返回false,因此您可能有一个空白文件或无效的语法。