rails设计,没有路由匹配注销 [英] rails devise, no route matches logout

查看:147
本文介绍了rails设计,没有路由匹配注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管有很多类似的问题,我已经搜索了几个小时,但仍然无法解决它。

Though there're lots of similar questions, i've searched for it for hours but still can not fix it.

Env
rails 3.0。 9
ruby​​ 1.9.2
devise 1.4.2

Env rails 3.0.9 ruby 1.9.2 devise 1.4.2

我使用以下方式更改了默认登录网址:

I changed the default login url using:

 5   resources :users
 6   devise_for :users, :path => "", :path_names => { :sign_in => 'login', :sign_out  
     => 'logout', :password => 'secret', :confirmation => 'verification', :unlock =>
     'unblock', :registration => 'register', :sign_up => 'cmon_let_me_in' }

http:// localhost:3000 / login 适用于我
但我包括

And the http://localhost:3000/login works fine for me But I include

 = link_to 'sign_out', destroy_user_session_path, :method => :delete

,我点击它后,它表示没有路由匹配/退出
为什么?
请帮助我。

in my application.haml, after i click it, it says that no route matchs "/logout" Why? Please help me.

推荐答案

我有一个几乎相同的问题,感谢SO很容易修复(链接到我的问题)。首先,确保您的布局文件application.html.erb中有<%= javascript_include_tag:defaults%>

I had a nearly identical problem and thanks to SO fixed it quite easily (link to my question). First, make sure you have <%= javascript_include_tag :defaults %> in your layout file "application.html.erb."

然后,在你的配置 - > initializers - >devise.rb文件中确保它说:

Then, in your config -> initializers -> "devise.rb" file make sure it says:

config.sign_out_via =:delete

和您的sign_out代码 destroy_user_session_path, method => :删除应该工作。

and your "sign_out" code destroy_user_session_path, :method => :delete should work.

这篇关于rails设计,没有路由匹配注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆