Rails routes /new(.:format)

前端 未结 1 1266
庸人自扰
庸人自扰 2021-01-20 14:57

Let\'s say I have a wordsController, I understand that

GET    /words(.:format)          /words#index

this route has a (.:format) at the en

相关标签:
1条回答
  • 2021-01-20 15:43

    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.

    0 讨论(0)
提交回复
热议问题