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