문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top