Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails delete not working inside twitter bootstrap dropdown (2.1.0)

I just upgraded the gem less-rails-bootstrap to use twitter bootstrap 2.1.0, and it seems to have broken this code in my view, inside a bootstrap dropdown:

<%= link_to 'Logout', destroy_admin_user_session_path, :method => :delete %>

The server seems to think this is a GET request instead of a DELETE. However, if I take that view code and put it immediately outside the dropdown, then it works great and the server recognizes the DELETE request.

If I change my gemfile as such:

gem 'less-rails-bootstrap', '~> 2.0.4'

Then run 'bundle update' and restart the server, then everything works as expected again. But if I simply have:

gem 'less-rails-bootstrap'

Then run 'bundle update' and restart the server, then the server thinks the DELETE is a GET request.

I tried switching to the gem 'twitter-bootstrap-rails', and the exact same issue occurs. I assume I must be doing something wrong?

like image 876
robotron2000 Avatar asked Aug 25 '12 09:08

robotron2000


2 Answers

Yeah, it's a Twitter Bootstrap issue. Probably will be fixed in the next release. Here, try this quick fix:

$('body')
  .off('click.dropdown touchstart.dropdown.data-api', '.dropdown')
  .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() });
like image 89
Volmer Avatar answered Nov 19 '22 09:11

Volmer


Apparently others are having the same issue as well: https://github.com/twitter/bootstrap/issues/4688

The quick fix with devise for now seems to be to change devise.rb to include:

config.sign_out_via = :get
like image 20
robotron2000 Avatar answered Nov 19 '22 10:11

robotron2000