Extract from Rails Routing from the Outside In
2.10.1 Adding Member Routes
To add a member route, just add a member block into the resource
block:resources :photos do member do get 'preview' end end
This will recognize /photos/1/preview with GET, and route to
the preview action of PhotosController, with the resource id value
passed inparams[:id]
. It will also create the preview_photo_url
and preview_photo_path helpers.Within the block of member routes, each route name specifies the HTTP
verb that it will recognize. You can use get, patch, put, post, or
delete here. If you don’t have multiple member routes, you can also
pass :on to a route, eliminating the block:resources :photos do get 'preview', on: :member end
And the actual answer to your question is in the last paragraph:
You can leave out the
:on
option, this will create the same member
route except that the resource id value will be available in
params[:photo_id]
instead ofparams[:id]
.
solved rails passing in id parameter ambiguous