Search code examples
ruby-on-railsherokumongoidstaging

Heroku staging app is crashing (unable to read environments/staging.rb)


I had a production app on Heroku - productionapp.heroku.com

So, I followed the steps to create a staging app for it:

1. heroku create stagingapp  --remote staging
2. heroku config:add RACK_ENV=staging  --app stagingapp
3. heroku addons:add mongohq:free  --app stagingapp
4. In config/mongoid.yml -
   add
     staging:
       uri: <%= ENV['MONGOHQ_URL'] %>
5. cp config/environments/production.rb config/environments/staging.rb
6. Add the MONGOHQ_URL in the mongohq.com connection.
6. git push staging master

The staging app is continuously crashing with the following backtrace:

2011-11-21T17:43:23+00:00 app[web.1]: 
You did not specify how you would like Rails to report deprecation notices for your staging environment,
please set config.active_support.deprecation to :log, :notify or :stderr at config/environment

2011-11-21T17:43:24+00:00 app[web.1]:
/app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.3.3/lib/mongoid/railtie.rb:64:in `block in <class:Railtie>':
undefined method `values' for nil:NilClass (NoMethodError)

2011-11-21T17:43:24+00:00 app[web.1]:
from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'

2011-11-21T17:43:24+00:00 app[web.1]:
from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'

2011-11-21T17:43:24+00:00 app[web.1]:
from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initialize

I have tried and retried these steps again and again and end up hitting the same error. It would be great if you could help me out!


Solution

  • i guess you did not add the configuration properly, because this is the line that fails in mongoid

    YAML.load(ERB.new(File.read(config_file)).result)[Rails.env].values.flatten.any?