I have a model Category in my Rails app. According to rails RESTful Routes, I can perform CRUD Operations on model, having resources: categories
defined in my routes.rb.
But how do i define destroy path helper in my view to perform DELETE
action, just like edit_category_path(@category)
to edit the record. I tried like this
destroy_category_path(@category)
but getting error as
undefined method `destroy_category_path' for #<#<Class:0x00000005371298>:0x000000053734f8>
The path is exactly the same as the show action ('/categories/:id'), but you also need to specify the DELETE
HTTP method:
button_to @category, method: :delete
Note, it is not considered safe to use links having destructive/constructive actions, as those might be visited by robots.
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