rails member routes

routes, ruby-on-rails

Solution

One is unified within default resource route declarations, IMO easier to find. The other isn't, which could lead to typos etc. Not a huge deal, but for RESTful actions, I'd rather use the resourceful mechanism.

You can also use the single-line version, which I prefer for single routes:

resources :cars do
  get :similar, :on => :member
end

Meagar is correct, I forgot that the match form will not create the helper methods.

Problem

I'm creating a route that should have a url of something like `http://mysite/cars/1/similar/`, which would get all cars similar to a car with the specified id (in this case 1) I've seen that you can create rails member routes in the routes.rb file with the syntax ``` resources :cars do member do get :similar end end ``` I can also do something like ``` match 'cars/:id/similar' => 'cars#similar', :via => "get ``` What is the difference between these two syntaxes

Original source