在我的routes.rb文件中,我有这段代码:
if Rails.env.development?
mount LetterOpenerWeb::Engine, at: "/letter_opener"
end
因为在开发模式下,我们希望letter_opener为我们打开电子邮件。但是当我推送到heroku时,我得到了这个(下面)。为什么是这样?为什么heroku忽略了我的routes.rb中的这一部分?
感谢任何可以提供帮助的人!
捆绑完成(23.08s) 清理捆绑缓存。 ----->为Rails资产管道准备应用程序 正在运行:rake assets:预编译 耙子流产了! NameError:未初始化的常量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&#39; /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.2/lib/action_dispatch/routing/route_set.rb:337:ineval_block' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.2/lib/action_dispatch/routing/route_set.rb:315:in
绘制&#39; /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/config/routes.rb:1:in load_paths中的<top (required)>' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:40:in
阻止&#39; /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:40:ineach' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:40:in
load_paths&#39; /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:16:inreload!' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:26:in
阻止更新程序&#39; /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.2/lib/active_support/file_update_checker.rb:75:incall' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.2/lib/active_support/file_update_checker.rb:75:in
执行&#39; /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/routes_reloader.rb:27:inupdater' /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&#39; /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application/finisher.rb:71:inblock 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&#39; /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/initializable.rb:30:in run_initializers中的run' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/initializable.rb:55:in
阻止&#39; /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/initializable.rb:54:inrun_initializers' /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application.rb:300:in
初始化&#39!; /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&#39!; /tmp/build_91bf7616fa162d43a8d71e23aeee1e99/vendor/bundle/ruby/2.1.0/gems/railties-4.1.2/lib/rails/application.rb:379:inblock 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
阻止(2级)定义&#39; 任务:TOP =&gt;环境 (通过使用--trace运行任务查看完整跟踪)! !预编译资产失败。
答案 0 :(得分:1)
我相信你必须指定你的运行时环境,在这种情况下你想要ENV =生产(根据上面输出中的请求表明&#34; require_environment!&#34;)。我不知道您正在运行哪个命令/任务会导致此错误,但请尝试将上述环境变量设置为&#39; production。&#39; (我不记得你是否需要关于单词制作的引用。)
答案 1 :(得分:0)
我在rake任务中有一行,强制任务仅在开发模式下运行。但是这一行超出了rake任务的范围,因此它影响了整个应用程序。