Question

I'm using friendly_id to make my URL's more user friendly, but since implementing the gem, my destroy action just goes to the show action. I'm currently using:

= link_to 'Delete', entry_path(e), :method => :delete, :confirm => 'Really really?'

and have also tried:

= link_to 'Delete', entry_path(e.id), :method => :delete, :confirm => 'Really really?'


The first gets routed to the show action of entries_controller and the second only gives me this error:

Routing Error

No route matches {:action=>"edit", :controller=>"entries", :id=>nil}


If anyone else has been using friendly_id, how did you take care of the Destroy action?

Was it helpful?

Solution

Have you integrated an ujs (e.g jquery-rails or jquery-ujs) js lib into the page? Because :method => :delete creates a data-method attribute and its click is then processed by the unobtrusive rails js library. If the link is not processed, it is either a simple show or a simple edit link instead of a link to the actual delete method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top