Reputation: 771
I want to have an Image controller and allow single endpoint such as:
/images/upload
but disable all the other default ones.
resources :images, only: [] do
collection do
post "upload"
end
end
This is my current approach that does the job, but is it the right one? Is there some sort of :none keyword to disable default routes? Or should i not use resources and do it some other way?
Upvotes: 0
Views: 158
Reputation: 106872
IMO uploading an image can be understood as creating an image, therefore I would simply use the create
method instead of an upload
method:
resources :images, only: [:create]
Upvotes: 1
Reputation: 11299
Just use a single post route:
post "/images/upload", to: "images#upload", as: :images_upload
Upvotes: 4