Why flash message won't disappear?

后端 未结 6 1229
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 17:06

I am doing some exception handling in my controller, when there is an exception thrown in :create action, I will render to the :new action and show a flash message.

6条回答
  •  生来不讨喜
    2020-12-07 17:54

    Replace

    flash[:alert] = t("uploading_error")
    

    with

    flash.now.alert = t("uploading_error")
    

    and see if that is the result you expect?

    flash[:alert] will stay around for the next page (hence it only disappears at the second redirect); but flash.now.alert will only display for the current page.

提交回复
热议问题