0
在我的Rails应用程序中,注销链接无法正常工作,我不知道我能做些什么来解决它。在我的Heroku的日志,当我尝试从我的用户帐户signout,我得到以下错误:我该如何解决这个路由错误?
的ActionController :: RoutingError(无路由匹配[GET] “/ signout”):
我有以下在我的配置路径/文件的routes.rb:
match '/signout', to: 'sessions#destroy', via: :delete
而在我的会话控制器我有以下方法:
def destroy
sign_out
redirect_to root_path
end
然后在我的session_shelper.rb文件我有后续荷兰国际集团SIGN_OUT方法:
def sign_out
self.current_user = nil
cookies.delete(:remember_token)
end
一切似乎是正确的从我的角度,所以我不知道是什么原因造成的错误,或者我怎么能解决这个问题。如果有帮助,我的应用程序托管在Heroku上。非常感谢!
sessions_controller.rb
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by_email(params[:session][:email])
if user && user.authenticate(params[:session][:password])
sign_in user
redirect_to info_path
else
flash.now[:error] = 'Invalid email/password combination'
render 'new'
end
end
def destroy
sign_out
redirect_to root_path
end
end
<nav>
<ul class="nav pull-right">
<% if signed_in? %>
<li><%= link_to "Settings", edit_user_path(current_user) %></li>
<li class="divider"></li>
<li><%= link_to "Sign out", signout_path, method: "delete" %></li>
</ul>
<% else %>
<li><%= link_to "Sign in", signin_path %>
<% end %>
</ul>
</nav>
好的,让我试试这个解决方案。非常感谢你! – user1483441 2012-08-17 16:54:27
@ user1483441你使用的是什么版本的导轨?,我编辑答案的方式。 – user1455116 2012-08-17 16:56:10
它没有工作。我仍然遇到同样的错误。 – user1483441 2012-08-17 16:59:26