That''s just not how Rails works. Your form posted to the Create action,
which is /object (and probably more likely objects/) and if you redirect you
lose the errors. You should ask yourself "Why does the URL matter?"
Your
users will be focused on filling in the correct info, not the URL. Make your
forms clear and most of your users won''t even see the errors on the
form at
all.
Using separate actions for new and create solves several other problems that
you may not yet notice. First, no branching logic to handle postbacks, and
second, a redirection away after a successful create prevents accidental
duplications on refresh.
Embrace the way Rails does things, and get your customers the features they
want. Best of luck to you.
On Tue, Sep 29, 2009 at 5:54 PM, Joao Silva <
rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:
>
> When I follow the standard:
>
> if @object.save
> redirect_to wherever
> else
> render :action => "new"
> end
>
> this changes the URL from /object/new to /object
>
> I want it to stay at /object/new
>
> thanks
> --
> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---