运行Rails 5并执行请求时遇到一些Devise错误

时间:2015-10-30 10:09:47

标签: ruby-on-rails devise webrick

当我检查Webrick日志时,我注意到以下内容:

Started GET "/tags" for 127.0.0.1 at 2015-10-30 08:16:58 +0000
/usr/local/rvm/gems/ruby-2.2.2/bundler/gems/rails-f7d0a3ba7e9e/actionpack/lib/action_controller/api.rb:110: warning: already initialized constant ActionController::API::MODULES
/usr/local/rvm/gems/ruby-2.2.2/bundler/gems/rails-f7d0a3ba7e9e/actionpack/lib/action_controller/api.rb:110: warning: previous definition of MODULES was here

ActionController::RoutingError (undefined method `helper_method' for ActionController::API:Class):
  app/controllers/application_controller.rb:1:in `<top (required)>'
  app/controllers/tags_controller.rb:1:in `<top (required)>'


  Rendered /usr/local/rvm/gems/ruby-2.2.2/bundler/gems/rails-f7d0a3ba7e9e/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.7ms)
  Rendered /usr/local/rvm/gems/ruby-2.2.2/bundler/gems/rails-f7d0a3ba7e9e/actionpack/lib/action_dispatch/middleware/templates/routes/_route.html.erb (8.6ms)
  Rendered /usr/local/rvm/gems/ruby-2.2.2/bundler/gems/rails-f7d0a3ba7e9e/actionpack/lib/action_dispatch/middleware/templates/routes/_table.html.erb (1.0ms)
  Rendered /usr/local/rvm/gems/ruby-2.2.2/bundler/gems/rails-f7d0a3ba7e9e/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.7ms)
  Rendered /usr/local/rvm/gems/ruby-2.2.2/bundler/gems/rails-f7d0a3ba7e9e/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (38.9ms) 

我检查了以下Github更新:

https://github.com/plataformatec/devise/issues/3690

但是当我尝试按照建议进行更新时:

https://github.com/rails/rails/pull/21151

我在这些文件中找不到上述信息:

https://github.com/rails/rails/commit/fd2508522c341c3f708219b5fc1834f24caf04e3

有什么想法吗?谢谢!

1 个答案:

答案 0 :(得分:0)

我有这个问题,我在git上找到了一些解决方案,我没有链接,但是就是这样:

您需要添加到application_controller.rb

def self.helper_method(*); end

如果你对...undefined method 'helper'...遇到同样的问题,请添加:

def self.helper(*); end

这解决了我的问题。 在我看来它不是最好的解决方案,但是直到设计将支持rails 5并且他们将它固定在他们身边,这种解决方法有效......