Ruby on Rails Tuesday, February 28, 2017

When you redirect, you lose all of the current environment (including the error, why it happened, etc.). This is almost never what you want to do. You want to fall through to re-render the form, and it will properly display the error messages and allow the user to recover without re-entering all of the data again. Use the rails scaffold command to make a new model/controller/view. Look at what it does. This is the expected behavior that you differ from at your peril!

Walter

> On Feb 28, 2017, at 10:51 AM, Joe Guerra <jguerra@jginfosys.com> wrote:
>
> I think you can use :back.
>
> redirect_to :back
>
> On Friday, February 24, 2017 at 1:10:31 PM UTC-5, fugee ohu wrote:
> my controller is user_posts_controller.rb
> it's views are in /app/views/user/posts
>
> when a form submission fails to save the object i wanna redirect back to the custom pathed form i came from but the controller code has render :new
>
> how do i redirect to the calling path of new and pass parameters
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a613cd5b-b474-41ee-85cb-42da2f274d54%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/F9CB9153-83B8-4539-A93C-B7A3AED6FCD5%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment