1

In my routes.rb file I have this code:

if Rails.env.development?
  mount LetterOpenerWeb::Engine, at: "/letter_opener"
end

Because in dev mode we like to have letter_opener open our emails for us. But when I push to heroku, I get this (below). Why is this? Why doesn't heroku ignore this section in my routes.rb?

thanks for anyone who can help!

Bundle completed (23.08s) Cleaning up the bundler cache. -----> Preparing app for Rails asset pipeline Running: rake assets:precompile rake aborted! NameError: uninitialized constant LetterOpenerWeb /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/config/routes.rb:43:in block in <top (required)>' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.2/lib/action_dispatch/routing/route_set.rb:337:in instance_exec' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.2/lib/action_dispatch/routing/route_set.rb:337:in eval_block' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.2/lib/action_dispatch/routing/route_set.rb:315:in draw' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/config/routes.rb:1:in <top (required)>' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:40:inblock in load_paths' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:40:in each' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:40:inload_paths' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:16:in reload!' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:26:inblock in updater' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.2/lib/active_support/file_update_checker.rb:75:in call' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.2/lib/active_support/file_update_checker.rb:75:in execute' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:27:in updater' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:7:in execute_if_updated' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/finisher.rb:71:in block in <module:Finisher>' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/initializable.rb:30:in instance_exec' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/initializable.rb:30:in run' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/initializable.rb:55:in block in run_initializers' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/initializable.rb:54:in run_initializers' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application.rb:300:in initialize!' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/config/environment.rb:5:in <top (required)>' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application.rb:276:in require_environment!' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application.rb:379:in block in run_tasks_blocks' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:55:in block (2 levels) in define' Tasks: TOP => environment (See full trace by running task with --trace) ! ! Precompiling assets failed.

2 Answers 2

1

I believe that you have to specify your runtime environment, which in this case you want to be ENV=production (as per the request in your output above that states "require_environment!"). I don't know what command/task you are running that causes this error, but try running with the above environment variable set to 'production.' (I can't remember if you need quotes around the word production or not.)

Sign up to request clarification or add additional context in comments.

1 Comment

This works for some reason I don't exactly understand.
0

I had a line in a rake task that forced the task to be run only in development mode. But that line was outside of the scope of the rake task, so it affected the entire application.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.