Reputation: 1795
Let's say I have a wordsController, I understand that
GET /words(.:format) /words#index
this route has a (.:format) at the end of the route so that I can choose different response format.
GET /words/new(.:format) /words#new
Why is there a (.:format) for the new action ?
Upvotes: 3
Views: 107
Reputation: 27961
It's not about querying words with conditions, it's about providing different formats for Rails to respond to. See the period? That's so you can do things like: /words.json
and get a JSON response, or /words.csv
and get a CSV response.
You're right that there's no reason to have a /words/new.json
URL, but Rails just adds the (.:format)
to all URLs just in case you need/want it for some format.
Upvotes: 3