原因閃光說是因爲用戶正在從after_resending_confirmation_instructions_path_for
方法重定向到new_session_path
「你已登錄」。我會覆蓋這個方法來檢查他們是否登錄。如果他們是,那麼不要重定向到new_session_path
,設置你的Flash消息並重定向到另一個頁面。
,將其置於controllers/users/confirmations_controller.rb
class Users::ConfirmationsController < Devise::ConfirmationsController
protected
def after_resending_confirmation_instructions_path_for(resource_name)
if signed_in?
flash[:notice] = "New message here" #this is optional since devise already sets the flash message
root_path
else
new_session_path(resource_name)
end
end
end
重寫確認控制器添加您confirmationsController到routes->
devise_for :users, :controllers => {:confirmations => 'users/confirmations' }
獲勝者獲勝者!奇蹟般有效。謝謝! – dpassage
很高興我能幫忙!我碰巧正在處理相同的用例。 – flynfish
我稍微改變了這個,使用下面的代碼來設置來自翻譯文件的flash消息,而不是:'set_flash_message(:notice,:send_instructions)' – dpassage