Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails / bootstrap delete link issue: data-method delete not working

I am using gem 'twitter-bootstrap-rails' for rails bootstrap

I have a few links on a page Rails code

<td><%= link_to 'Destroy', swimming_classschedule, method: :delete, data: { confirm: 'Are you sure?' } %></td>

 <li> <%= link_to "Logout", destroy_user_session_path, method: :delete, :class => 'navbar-link'  %> </li>

html code:

     <a href="/users/sign_out" class="navbar-link" data-method="delete" rel="nofollow">Logout</a>

<td><a href="/swimming/students/1" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a></td>

      <td><a href="/swimming/students/3" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a></td>

Whenever I click to delete a student I got logged out. I am totally confused

like image 224
wwli Avatar asked Dec 11 '22 14:12

wwli


1 Answers

I had the same problem.. I read in the forums that it was due to javascript issues.

In application.js, I previously removed the original files because I thought they weren't needed as I was using bootstrap.js. I put it back in the file and now the delete method works again!

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require_tree .
like image 96
Bilton Tran Avatar answered Dec 17 '22 22:12

Bilton Tran