0

使用 Rails 3.2。我有以下

# application.rb
document   = YAML.load(File.read(File.expand_path('../app_config.yml', __FILE__)))
APP_CONFIG = document[Rails.env].merge(document['global'])

# app_config.yml
global:
  site_name_lowercase: abc

staging:
  site_domain: 192.168.33.10
  site_url: http://192.168.33.10

development:
  site_domain: abc.dev
  site_url: http://abc.dev

当我尝试运行时rails c RAILS_ENV=staging,我得到以下信息:

/home/deployer/abc/releases/20131015193830/config/application.rb:9:in `<top (required)>': undefined method `merge' for nil:NilClass (NoMethodError)
    from /home/deployer/abc/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:39:in `require'
    from /home/deployer/abc/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:39:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

它指向merge. application.rbrails c在开发环境中运行,效果很好。开发环境中的一切工作正常,从读取app_config.yml到解析它的内容。我怎样才能解决这个问题?

4

1 回答 1

1

尝试bundle exec rails c staging代替rails c RAILS_ENV=staging.

于 2013-10-16T09:40:33.583 回答