4

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

1
  • 1
    And if you remove logout link, what happens then? You use Devise? Isn't the log saying WARNING: Can't verify CSRF token authenticity Commented Jun 23, 2013 at 20:45

2 Answers 2

12

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 .
Sign up to request clarification or add additional context in comments.

3 Comments

I added only jquery_ujs after jquery, which is the responsible for that
Hi @juanpastas, Thank you for your commennt! I have added the jquery_ujs after jquery, then it works perfectly.
In my case I had to do something a little bit different. I added this to my application.js file: import Rails from '@rails/ujs'; Rails.start();
2

based on this answer Delete link sends "Get" instead of "Delete" in Rails 3 view

I added

<%= csrf_meta_tag %>

in header, which fixed the issue

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.