What would the difference be?
Example Match:match 'photos/show' => 'photos#show'
Example Get:get 'photos/show'
Wouldn't both make it possible to reach the photos/show URL and also use the show action in the photos controller?
Thanks
Rails routes are matched in the order they are specified, so if you have a resources :photos above a get 'photos/poll' the show action's route for the resources line will be matched before the get line. To fix this, move the get line above the resources line so that it is matched first.
Rails RESTful Design which creates seven routes all mapping to the user controller. Rails also allows you to define multiple resources in one line.
Rails routing is a two-way piece of machinery – rather as if you could turn trees into paper, and then turn paper back into trees. Specifically, it both connects incoming HTTP requests to the code in your application's controllers, and helps you generate URLs without having to hard-code them as strings.
Singular routes* are a little different – they are written as singular resource . Declaring a resource or resources generally corresponds to generating many default routes. resource is singular. resources is plural.
match
matches any http method/verb, while get
matches only http method/verb GET.
Following two are equivalent:
match "/signup" => "users#new", :via => [:get] get "/signup" => "users#new"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With