Ruby on Rails Wednesday, December 1, 2010

On 1 December 2010 15:39, Leonel *.* <lists@ruby-forum.com> wrote:
> By default, the controllers are coded in a way that you will be
> redirected to the SHOW page of the item you are updating.
>
> For example, if I edit a user, after I click the submit button, I will
> be redirected to the SHOW page of that users.
>
> Instead of being redirected to the SHOW page, I want to stay in the same
> EDIT page with a notice that the user has been updated. How can I
> accomplish that?
>
> I tried this...
> format.html { redirect_to(:action => 'edit' , :notice => 'User was
> successfully updated.') }

You don't want the :notice bit, just make sure that the flash is shown
on the edit page as it is on the show page. Probably something like
<p style="color: green"><%= flash[:notice] %></p>
in the layout. and set flash[:notice] in the update action (which it
probably is already).

Colin

>
> And it did get me redirected to the EDIT form. But I don't see the
> notice message and the resulting URL is this:
> http://localhost:3000/users/4/edit?notice=User+was+successfully+updated.
>
> So I must be doing something wrong.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> 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.
>
>

--
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