Devise 使我的 rails 应用程序在 heroku 上崩溃,"undefined local variable or method `mimes_for_respond_to'"
Devise crashes my rails app on heroku, "undefined local variable or method `mimes_for_respond_to'"
自从添加设计 gem 后,heroku 无法在生产环境中加载我的应用程序,出现应用程序错误:
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
控制台的具体错误日志是
/app/vendor/bundle/ruby/2.1.0/gems/devise-3.3.0/app/controllers/devise_controller.rb:13:in `<class:DeviseController>': undefined local variable or method `mimes_for_respond_to' for DeviseController:Class (NameError)
from /app/vendor/bundle/ruby/2.1.0/gems/devise-3.3.0/app/controllers/devise_controller.rb:2:in `<top (required)>'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `block in require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:360:in `require_or_load'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:494:in `load_missing_constant'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:184:in `const_missing'
from /app/vendor/bundle/ruby/2.1.0/gems/devise-3.3.0/app/controllers/devise/confirmations_controller.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `block in require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:360:in `require_or_load'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:317:in `depend_on'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:233:in `require_dependency'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:471:in `each'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:471:in `block in eager_load!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:469:in `each'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:469:in `eager_load!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:346:in `eager_load!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/application/finisher.rb:56:in `each'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:30:in `instance_exec'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:30:in `run'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:55:in `block in run_initializers'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:54:in `run_initializers'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/application.rb:352:in `initialize!'
from /app/config/environment.rb:5:in `<top (required)>'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `block in require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/application.rb:328:in `require_environment!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/commands/commands_tasks.rb:142:in `require_application_and_environment!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/commands/commands_tasks.rb:67:in `console'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/commands.rb:17:in `<top (required)>'
from /app/bin/rails:8:in `require'
from /app/bin/rails:8:in `<main>'
我尝试了互联网上流传的多种建议,但 none 到目前为止都有效。提前致谢!
快速 google 搜索将您的问题与需要更新的 responders
gem 联系起来。请看this issue in Devise gem。只要 responders
是 Devise
依赖项,您就不需要将其包含在 Gemfile
中(在您的 Gemfile.lock
中仔细检查),您只需要更新到最新版本:
bundle update responders
如果 responders
gem 不可用,则将 gem 'responders'
添加到您的 Gemfile
之前 运行 上一个命令。
希望对您有所帮助。
自从添加设计 gem 后,heroku 无法在生产环境中加载我的应用程序,出现应用程序错误:
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
控制台的具体错误日志是
/app/vendor/bundle/ruby/2.1.0/gems/devise-3.3.0/app/controllers/devise_controller.rb:13:in `<class:DeviseController>': undefined local variable or method `mimes_for_respond_to' for DeviseController:Class (NameError)
from /app/vendor/bundle/ruby/2.1.0/gems/devise-3.3.0/app/controllers/devise_controller.rb:2:in `<top (required)>'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `block in require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:360:in `require_or_load'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:494:in `load_missing_constant'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:184:in `const_missing'
from /app/vendor/bundle/ruby/2.1.0/gems/devise-3.3.0/app/controllers/devise/confirmations_controller.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `block in require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:360:in `require_or_load'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:317:in `depend_on'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:233:in `require_dependency'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:471:in `each'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:471:in `block in eager_load!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:469:in `each'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:469:in `eager_load!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:346:in `eager_load!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/application/finisher.rb:56:in `each'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:30:in `instance_exec'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:30:in `run'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:55:in `block in run_initializers'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:54:in `run_initializers'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/application.rb:352:in `initialize!'
from /app/config/environment.rb:5:in `<top (required)>'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `block in require'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc3/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/application.rb:328:in `require_environment!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/commands/commands_tasks.rb:142:in `require_application_and_environment!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/commands/commands_tasks.rb:67:in `console'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.rc3/lib/rails/commands.rb:17:in `<top (required)>'
from /app/bin/rails:8:in `require'
from /app/bin/rails:8:in `<main>'
我尝试了互联网上流传的多种建议,但 none 到目前为止都有效。提前致谢!
快速 google 搜索将您的问题与需要更新的 responders
gem 联系起来。请看this issue in Devise gem。只要 responders
是 Devise
依赖项,您就不需要将其包含在 Gemfile
中(在您的 Gemfile.lock
中仔细检查),您只需要更新到最新版本:
bundle update responders
如果 responders
gem 不可用,则将 gem 'responders'
添加到您的 Gemfile
之前 运行 上一个命令。
希望对您有所帮助。