没有路由匹配“/users/sign_out"设计铁轨 3 [英] No route matches "/users/sign_out" devise rails 3
问题描述
我已经在我的应用程序上安装了设计,并在我的 application.html.erb
文件中应用了以下内容:
I've installed devise on my app and applied the following in my application.html.erb
file:
<div id="user_nav">
<% if user_signed_in? %>
Signed in as <%= current_user.email %>. This cannot be cheese?
<%= link_to 'Sign out', destroy_user_session_path %>
<% else %>
<%= link_to 'Register', new_user_registration_path %> or <%= link_to 'Sign in', new_user_session_path %>
<% end %>
</div>
我运行 rake routes
并确认所有路由都有效.
I ran rake routes
and confirmed that all the routes are valid.
另外,在我的 routes.rb
文件中,我有 devise_for :users
和 root :to =>home#index"
.
Also, in my routes.rb
file I have devise_for :users
and root :to => "home#index"
.
单击退出"链接时出现以下路由错误:
I get the following routing error when clicking the "Sign out" link:
No route matches "/users/sign_out"
任何想法是什么导致了错误?
Any ideas what's causing the error?
推荐答案
我认为退出的路径是 DELETE
方法.这意味着您的退出链接需要如下所示:
I think the route for signing out is a DELETE
method. This means that your sign out link needs to look like this:
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
你的不包括 :method =>:delete
部分.另外,请注意,要使其正常工作,您还必须在布局文件 (application.html.erb
) 中包含 <%= javascript_include_tag :defaults %>
.
Yours doesn't include the :method => :delete
part. Also, please note that for this to work you must also include <%= javascript_include_tag :defaults %>
in your layout file (application.html.erb
).
这篇关于没有路由匹配“/users/sign_out"设计铁轨 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!