How to render edit view and post flash message in rails3

前端 未结 3 430
说谎
说谎 2021-02-05 02:10

In my account controller I\'d like to display (render, redirect_to ?) the edit view after changes get saved and display flash notice.

 def update
    @account =         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-05 02:45

    If you just use flash[:notice] that value will still be available in the next request. Meaning, you'll see the text on the next 2 pages. Instead use flash.now to only make the value available in the current request.

    format.html { 
      flash.now[:notice] = 'message'
      render :edit
    }
    

    For reference read Action Controller Overview 5.2.1

提交回复
热议问题