Rails app crashes when config.eager_load=true <p>I have a Rails application and an Engine. </p> <p>When i have config.eager_load= true in my environments/production.rb the app crashes giving the following error in the engine </p> <pre><code>FATAL: ActionView::Template::Error(undefined local variable or method `current_user' for #&lt;#&lt;Class:0x00000005812fe0&gt;:0x00000005811e88&gt;) /var/www/rack_apps/manager/shared/vendor_bundle/ruby/2.1.0/gems/authorization_engine-0.1.0.SNAPSHOT.20140407182910/app/views/authorization_engine/authorizations/new.html.haml:26:in `__var_www_rack_apps_manager_shared_vendor_bundle_ruby_______gems_authorization_engine_______________________________app_views_authorization_engine_authorizations_new_html_haml__268041456534634533_46121540' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/template.rb:143:in `block in render' vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:161:in `instrument' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/template.rb:141:in `render' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument' vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:159:in `block in instrument' vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications/instrumenter.rb:20:in `instrument' vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:159:in `instrument' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:48:in `block in render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:47:in `render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:17:in `render' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/renderer.rb:42:in `render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/renderer.rb:23:in `render' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/abstract_controller/rendering.rb:127:in `_render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_controller/metal/streaming.rb:219:in `_render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/abstract_controller/rendering.rb:120:in `render_to_body' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_controller/metal/rendering.rb:33:in `render_to_body' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_controller/metal/renderers.rb:26:in `render_to_body' </code></pre> <p>But the same above seems to work if i set the config.eager_load = false</p> <p>Is this normal ? ... I know you shouldn't be setting eager_load to false in production. Is there a way not to eager load the engine or have i got the entire concept wrong ?</p> <p>I know it says undefined variable current_user but it picks it up perfectly when i run locally . Any suggestions or ideas would be awesome .Thanks</p>