respond_with redirect with notice flash message not working

前端 未结 3 1591
栀梦
栀梦 2021-01-14 09:21

I am using rails 3.0.7. In the controller I have:

  def create
    @subscription = Subscription\\
      .new_from_nested_attributes_parameters(params[:subscr         


        
3条回答
  •  臣服心动
    2021-01-14 09:42

    I discovered the problem.

    flash[:notice]="...." is properly working on the create action, redirecting to the show action.

    What I forgot was that my 'show' consists on a redirect to edit.

    I fixed this by implementing the show action like this:

    def show
      redirect_to edit_subscription_path(@subscription),flash
    end
    

    From Rails 3.1 on, this should be accomplished with:

    def show
      flash.keep
      redirect_to edit_subscription_path(@subscription)
    end
    

提交回复
热议问题