有設計問題。我有一個註冊的網址,其中包括令牌......是這樣的:本地主機:3000 /用戶/ sign_up/df293b00ae137b8b6436d45e622304aedc549072Rails/Devise:註冊失敗後,我如何重定向回來並顯示Flash消息?
當註冊失敗(密碼不匹配或某物)的應用重定向到本地主機:3000 /用戶,並顯示來自模型的正確的閃光消息。
但是我需要應用程序重新導向回到具有令牌的網址。所以我把redirect_to:放回到控制器中,讓我回來,但閃光消息不顯示。
如何讓頁面重定向回來(保留確切的url)並仍然顯示flash消息。
下面是從色器件控制器代碼:
def new
resource = build_resource({})
respond_with resource
end
# POST /resource
def create
build_resource
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_up(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
respond_with resource
end
end
任何幫助將是巨大的!
您是否嘗試過使用'flash.keep'前'redirect_to的:back'?這聽起來像Flash不是重定向的倖存者。 –
是的,沒有骰子:(只是重定向回來沒有閃光信息 –
重定向可能本身重定向了嗎?沿着[這個答案](http://stackoverflow.com/a/12880760/771564)。 –