Issue with delete action

I have a problem with my delete action and link. Here is my link :

<%= link_to 'Supprimer la thématique', @theme, method: :delete, data: { confirm:'Êtes-vous sûr de vouloir supprimer la thématique' }, :class => "btn btn-default" %>

And I don't know why, but this link redirect to the show action of my model 'theme'.

I can resolve this by using button_to but with a button_to I'm not able to set a data confirm :

<%= button_to "Supprimer la thématique", @theme, :method=>:delete, data: { confirm: 'Êtes-vous sûr de vouloir supprimer la thématique ?'}, :class=> 'btn btn-default' %>

Do you have any ideas why the link to doesn't redirect to the delete action or why I can't have a data confirm for my button_to ?


Clicking a link always sends a GET request, unless there's Javascript in place that does something different, such as sending an Ajax request or submitting a hidden form. When using regular resourceful routes, the show action and destroy action share a route, and determine what to do based on the method (as you probably know).

The button_to method should support a confirmation dialog; if it doesn't work, then there's probably some Javascript missing.

Both your problems point to a missing unobtrusive Javascript driver. If using jquery-rails (the standard option), make sure that it's listed in your Gemfile:

gem 'jquery-rails'

and that you're loading it in your application.js:

//= require jquery
//= require jquery_ujs

Also be sure that you're calling the javascript_include_tag method in your application layout. Once you've got jquery-rails loaded properly, you should be able to get the results you're looking for with either method you've attempted.

For more information on loading jquery-rails, see the Github repo.

Need Your Help

Eclipse freezes UI on Ubuntu

java eclipse user-interface ubuntu freeze

I have recently installed ubuntu 16.04 (updated automatically to this version) and I usually develop in Java, and I know eclipse, so I installed it, all fine.

Call to undefined function App\belongsToMany [Laravel]

php laravel laravel-5 eloquent

The error i am getting is "Call to undefined function App\belongsToMany".