Reputation: 10360
When creating a new controller post in rails with command rails generate controllers post
, routes started with get
will be inserted into the top of routes.rb automatically like below:
get "posts/index"
get "posts/new"
get "posts/create"
get "posts/edit"
get "posts/update"
get "posts/show"
We notice that the rails routing works the same after deleting those routes. We just found out that one of routes caused error in rails engine routing and it has to be deleted. We haven't found documents about those automatically generated routes. What's the purpose of those routes and is there any use of them in rails app?
Upvotes: 0
Views: 256
Reputation: 6419
The 'get' is the HTTP verb supported by the routing engine. It's possible to route GET and POST (and the rest) to different methods, even if they hit the same URL. It's also possible to only support certain verbs for certain URLs (as is happening here).
Regarding their necessity - we'd have to see the rest of your routes.rb file to know. If you have a default match rule, that likely will take effect if these are removed.
Upvotes: 1