Ruby on Rails Wednesday, December 1, 2010

On Dec 1, 11:12 am, "Leonel *.*" <li...@ruby-forum.com> wrote:
> ALRIGHT!! AWESOME!!!
>
> Simple and it works!
>
> I did this...
>
> flash[:notice] = 'User was successfully updated.'
> respond_to do |format|
>   if @user.update_attributes(params[:user])
>     format.html { redirect_to(:action => 'edit') }
>     format.xml  { head :ok }
>   else

There is a shorthand for specifying the "notice" flash in the
redirect_to call. You were very close to having it correct.

The format is this: redirect_to(options = {}, response_status = {})

The :notice needs to be in the response_status hash.

The problem you had is that that :action and :notice were both passed
in the options hash. You can use the shorthand by explicitly
separating the hashes:

redirect_to( { :action => 'edit' }, :notice => 'User was successfully
updated.' )

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment