Reputation: 5462
So right now in a Rails 5 heroku review app, RAILS_ENV is set to "production" in the config vars section. If I change the value to "staging" and try to run rails console on the heroku review app, it crashes with an error output of:
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
* development - set it to false
* test - set it to false (unless you use a tool that preloads your test environment)
* production - set it to true
/app/vendor/bundle/ruby/2.3.0/gems/devise-4.1.1/lib/devise/rails/routes.rb:498:in `raise_no_secret_key': Devise.secret_key was not set. Please add the following to your Devise initializer: (RuntimeError)
config.secret_key = 'xxx'
Please ensure you restarted your application after installing Devise or setting the key.
from /app/vendor/bundle/ruby/2.3.0/gems/devise-4.1.1/lib/devise/rails/routes.rb:226:in `devise_for'
from /app/config/routes.rb:6:in `block in <top (required)>'
from /app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:389:in `instance_exec'
from /app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:389:in `eval_block'
from /app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:371:in `draw'
from /app/config/routes.rb:1:in `<top (required)>'
Does setting the RAILS_ENV to "staging" mean I have to create a config/staging.rb file because Rails will infer environmental settings from there?
Upvotes: 1
Views: 1227
Reputation: 5462
As it turns out, 3 things were needed:
I had to set RAILS_ENV to staging in the Heroku config vars section on the heroku review app. I created a config/environments/staging.rb file which was a copy of config/environments/development.rb. I also had to add generate a secret key using bundle exec rake secret and copy and paste that value into config/secrets.yml under a nested yaml key of
staging:
secret_key_base: 12345xxy
Upvotes: 4