当我退出时,我的导航不会改变,以反映我在刷新页面之前已退出。
我这样设置:
<%- if !user_signed_in? %>
<li>
<%= link_to "Sign up", new_registration_path(:user) %><br />
</li>
<li>
<%= link_to "Sign in", new_user_session_path %><br />
</li>
<% else -%>
<li>
<%= link_to "Sign Out", destroy_user_session_path(:user), :method => :delete %>
</li>
<% end -%>
我的routes.rb非常简单:
Rails.application.routes.draw do
devise_for :users, controllers: { sessions: "users/sessions" }
root 'home#index'
end
破坏功能如下所示:
def destroy
super
end
private
# Overwriting the sign_out redirect path method
def after_sign_out_path_for(user)
root_path
end