設計行爲奇怪。它顯示紅色或錯誤消息,但不顯示綠色或成功消息。設計不顯示成功消息
這是在我根據用戶是否登錄的情況對路由和控制器進行更改以重定向到登錄頁面或主頁之後發生的。
所以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
當你登錄或註銷時,你對閃存對象有什麼看法我想設計把這些信息寫成'flash [:notice]'而不是'flash [:success]' – Viren
是的!它當然是'flash [:notice]'。通過成功消息我的意思是說你已經登錄或退出成功的消息。設計用綠色背景標記它們。 – Humming
我很確定背景顏色,但如果你關心的是flash消息檢查'devise.yml'(在'config/locales'目錄下)文件會給你更多的洞察吧 – Viren