You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have my app running in Test mode on Heroku. switch_user works well locally with Test mode but causes an exception on Heroku so that the app cannot start
I add config/initializers/switch_user.rb with these changes (to run in Test mode):
27config.controller_guard=lambda{ |current_user,request| Rails.env.development? || Rails.env.test?}2829# view_guard is a block,30# if it returns true, the switch user select box will be shown,31# else the select box will not be shown32# if you switch from admin to "user", the current_user param is "user"33config.view_guard=lambda{ |current_user,request| Rails.env.development? || Rails.env.test?}
And this is the error message on Heroku logs:
2011-09-21T02:32:27+00:00app[web.1]: /app/config/initializers/switch_user.rb:1:in`<top (required)>': uninitialized constant SwitchUser (NameError)2011-09-21T02:32:27+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.10/lib/rails/engine.rb:201:in `block(2levels)in <class:Engine>'2011-09-21T02:32:27+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.10/lib/rails/engine.rb:200:in `each'2011-09-21T02:32:27+00:00app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.10/lib/rails/engine.rb:200:in`block in <class:Engine>'2011-09-21T02:32:27+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.10/lib/rails/initializable.rb:25:in `instance_exec'2011-09-21T02:32:27+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.10/lib/rails/initializable.rb:25:in `run'2011-09-21T02:32:27+00:00app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.10/lib/rails/initializable.rb:50:in`block in run_initializers'2011-09-21T02:32:27+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.10/lib/rails/initializable.rb:49:in `each'2011-09-21T02:32:27+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.10/lib/rails/initializable.rb:49:in `run_initializers'2011-09-21T02:32:27+00:00app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.10/lib/rails/application.rb:134:in`initialize!'2011-09-21T02:32:27+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.10/lib/rails/application.rb:77:in `method_missing'2011-09-21T02:32:27+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>'2011-09-21T02:32:27+00:00app[web.1]: from <internal:lib/rubygems/custom_require>:29:in`require'2011-09-21T02:32:27+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require'2011-09-21T02:32:27+00:00 app[web.1]: from config.ru:3:in `block (3 levels) in <main>'
The text was updated successfully, but these errors were encountered:
Your Gemfile probably has something like this (or a variant of it):
group:development,:testdogem'switch_user'end
Most (all recent unless you change it) Heroku applications are created the following under heroku config:
BUNDLE_WITHOUT => development:test
Which means, since you have your Heroku instance configured to run with RAILS_ENV=test, that when you deploy bundler doesn't even bother installing switch_user and therefore won't try to load it. Ultimately that means that when your initializer runs, SwitchUser hasn't been defined and you end up with a NameError.
I'm using Cedar stack which heroku config output doesn't contain BUNDLE_WITHOUT configuration as Bamboo.
Anyway, I tried to move switch_user outside the dev/test scopes then it works.
I have my app running in Test mode on Heroku. switch_user works well locally with Test mode but causes an exception on Heroku so that the app cannot start
I add config/initializers/switch_user.rb with these changes (to run in Test mode):
And this is the error message on Heroku logs:
The text was updated successfully, but these errors were encountered: