Ruby on Rails Routes - difference between get and

2020-02-16 08:12发布

问题:

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

回答1:

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"