ruby on rails - Issue with delete action -
i have problem delete action , link. here 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 don't know why, link redirect show action of model 'theme'.
i can resolve using button_to button_to i'm not able set 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 have ideas why link doesn't redirect delete action or why can't have data confirm button_to ?
clicking link sends request, unless there's javascript in place different, such sending ajax request or submitting hidden form. when using regular resourceful routes, show action , destroy action share route, , determine based on method (as know).
the button_to method should support confirmation dialog; if doesn't work, there's javascript missing.
both problems point missing unobtrusive javascript driver. if using jquery-rails (the standard option), make sure it's listed in gemfile:
gem 'jquery-rails' and you're loading in application.js:
//= require jquery //= require jquery_ujs also sure you're calling javascript_include_tag method in application layout. once you've got jquery-rails loaded properly, should able results you're looking either method you've attempted.
for more information on loading jquery-rails, see the github repo.
Comments
Post a Comment