Is it possible to specify a put or delete http verb from the route.rb, for a specific path?
Like:
get 'photos/show'
I tried to do it with match like the below:
match 'photos/show' => 'photos#show', :via => :delete
In the rake routes it seems right but it doesn't do a delete http request. Also I tried:
match 'photos/show' => 'photos#show', :via => :random
And in the rake routes its shows "random"
It seems that you can specify get or post as shown in the guides, but I don't know if I can specify put or delete. Is it possible?
put 'photos/:id(.:format)', :to => 'photos#update'
delete 'photos/:id(.:format)', :to => 'photos#destroy'
or
resources :photos
and hit your app directory with
rake routes
C'mon, you're not even trying!
Nothing prevents you from using put/post/delete 'directly', in place of match.
As an example, this works for me:
get 'user/edit' => 'users#edit', :as => :edit_current_user
put 'signup' => 'users#update'
The via option is useful when you want to route like eg this (not a frequent case, though):
match 'user/show' => 'users#show', :via => [:get, :post]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With