当我从我的应用程序点击注销时出现以下路由错误,其中使用设计3.2.2管理身份验证。
Routing Error
No route matches [GET] "/users/sign_out"
Try running rake routes for more information on available routes.
这是生成链接的haml行。
%li= link_to('Logout', destroy_user_session_path, :method=>'delete')
这是生成的html:
<a href="/users/sign_out" data-method="delete" rel="nofollow">Logout</a>
这是通话的日志:
Started GET "/users/sign_out" for 127.0.0.1 at 2014-02-09 22:04:34 +0100
ActionController::RoutingError (No route matches [GET] "/users/sign_out"):
actionpack (3.2.16) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.16) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.16) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.16) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.16) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.16) lib/rails/rack/logger.rb:16:in `call'
quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
actionpack (3.2.16) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.16) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.16) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.16) lib/rails/engine.rb:484:in `call'
railties (3.2.16) lib/rails/application.rb:231:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.16) lib/rails/rack/log_tailer.rb:17:in `call'
thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process'
thin (1.5.1) lib/thin/connection.rb:79:in `catch'
thin (1.5.1) lib/thin/connection.rb:79:in `pre_process'
thin (1.5.1) lib/thin/connection.rb:54:in `process'
thin (1.5.1) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.5.1) lib/thin/backends/base.rb:63:in `start'
thin (1.5.1) lib/thin/server.rb:159:in `start'
rack (1.4.5) lib/rack/handler/thin.rb:13:in `run'
rack (1.4.5) lib/rack/server.rb:268:in `start'
railties (3.2.16) lib/rails/commands/server.rb:70:in `start'
railties (3.2.16) lib/rails/commands.rb:55:in `block in <top (required)>'
railties (3.2.16) lib/rails/commands.rb:50:in `tap'
railties (3.2.16) lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
这曾经在过去工作过,我不确定发生了什么以及为什么它不再起作用了。
任何线索?
谢谢,
答案 0 :(得分:0)
使用method: 'delete'
需要包含jquery_ujs
(适用于不支持数据方式的浏览器)。
确认您正在加载application.js
并且该文件包含行//= require jquery_ujs
答案 1 :(得分:0)
我无法找到为什么UJS在这种情况下不能使用方法删除生成正确的请求,我怀疑这是与chrome相关的。
我改变了这个:
config.sign_out_via =:get
config/initializers/devise.rb
中的
这现在有效。