没有路由匹配" /用户/ SIGN_OUT"制定轨道3 [英] No route matches "/users/sign_out" devise rails 3
问题描述
application.html.erb
文件中应用了以下内容: < div id =user_nav>
<%user_signed_in? %GT;
以<%= current_user.email%> ;.登录。这不能是奶酪?
<%= link_to'注销',destroy_user_session_path%>
<%else%>
<%= link_to'Register',new_user_registration_path%>或<%= link_to'登录',new_user_session_path%>
<%end%>
< / div>
我跑了 rake路线
并确认所有路线是有效的。
此外,在我的 routes.rb
文件中我有 devise_for :用户
和 root:to => 回家#指数
。
点击退出链接时,出现以下路由错误:
没有路线匹配/ users / sign_out
任何想法是什么导致错误? / p>
我认为退出的路由是一个 DELETE
方法。这意味着您的登出链接需要如下所示:
<%= link_to退出,destroy_user_session_path, method => :删除%>
您的不包含:method => :删除
部分。另外,请注意,为了使其工作,您还必须在布局文件( application.html)中包含
)。<%= javascript_include_tag:defaults%>
.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>
I ran rake routes
and confirmed that all the routes are valid.
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?
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 %>
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
).
这篇关于没有路由匹配" /用户/ SIGN_OUT"制定轨道3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!