I am fairly new to Rails and I am trying to understand the default routes 
generated by resources in routes.rb

Is there a justification for having the default route generated by 
resources for create as "/things"

           POST   /things(.:format)          {:action=>"create", 
:controller=>"things"}

Wouldn't it be a better idea to have something like 

create_things POST   /things/new(.:format)      {:action=>"create", 
:controller=>"things"}

I came across a scenario where this seems to be a problem.

1. User fills in a form at /things/new

2. Submits the form with invalid form fields.

3. render "new" is called from create action to display the error messages.

4. new form is rendered but because of create action being mapped to /things, 
the URL now points to /things.

5. This is confusing for the user as he expects to go to index page by this 
URL. But here the URL points to /things and it has the new form.

6. Wouldn't it be a better interface for the user if we have default POST   
/things/new for create, which will take keep the user on the same URL 
/things/new when invalid form is submitted.

I was curious about why do we have the default route for create as /things. Is 
there a use-case that I am missing ?

- Harshal


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/ixbl-bto5J4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to