在 Mongoid 方法调用上使用 Capistrano deploy Rails:NoMethodError

Using Capistrano deploy Rails:NoMethodError on Mongoid method call

我是 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, 'git@git.coding.net: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。您已将其设置为对该文件进行符号链接,但由于加载它 returns false,您可能有一个空白文件或无效语法。