设计的行为很奇怪。它显示红色或错误消息,但不显示绿色或成功消息。
这发生在我对路由和控制器进行更改以根据用户是否登录重定向到登录页面或主页之后。
所以 routes.rb 现在有:
devise_for :users
root :to => "questions#redirect_on_visit"
match 'home', :to => "questions#index"
和控制器:
before_filter :authenticate_user!, :except => [:redirect_on_visit]
def redirect_on_visit
if user_signed_in?
redirect_to home_path
else
redirect_to new_user_session_path
end
end
还更改了应用程序控制器以在登录/注销后重定向到适当的页面:
protected
def after_sign_in_path_for(resource)
stored_location_for(:user) || root_path
end
private
def after_sign_out_path_for(resource)
stored_location_for(:user) || root_path
end