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

问题描述

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

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

环境导轨 3.0.9红宝石 1.9.2设计1.4.2

Envrails 3.0.9ruby 1.9.2devise 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 meBut I include

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

在我的 application.haml 中,单击它后,它说没有路由匹配/logout"为什么?请帮帮我.

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."

然后,在你的 config -> 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 =>:delete 应该可以工作.

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

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

06-16 02:57