resources :books, only: [:index, :show] do
collection do
get 'search'
put '/:id/upvote', to: 'books#upvote'
put '/:id/downvote', to: 'books#downvote'
delete '/:id/unvote', to: 'books#unvote'
put '/:id/track', to: 'books#track'
end
end
"collection" is for the whole ressource (without '/:id/'), not a specific member. It should be done that way when you use the id of a member of a resource:
member do
put 'upvote'
put 'downvote'
delete 'unvote'
put 'track'
end
You can also note that the "to:" are unnecessary, it already knows where to go
"collection" is for the whole ressource (without '/:id/'), not a specific member. It should be done that way when you use the id of a member of a resource:
You can also note that the "to:" are unnecessary, it already knows where to go
You can find some documentation on the subject there: https://guides.rubyonrails.org/routing.html#adding-more-restful-actions