Question

So I have built a mountable Engine and added devise for authentication:

And for some reason the :delete method on links is performing a get here is the relevant code:

Index.html.erb

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

Config/initializers/devise.rb

config.sign_out_via = :delete

Routes

destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy

Error

No route matches [GET] "/my_engine/users/sign_out"

changing config.sign_out_via = :delete to config.sign_out_via = :get fix's the problem and allows me to sign_out however this is the wrong way to do things a signout should be a delete and would love to get this working if anyone has any ideas

Additional Info (Gems + Ruby Version + Actual HTML displayed on page for logout link)

I am using ruby-1.9.3-p398

this is the html displayed on page for layout link

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

and the gems:

Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.8.4)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.2)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.2)
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.2)
Using activemodel (4.0.2)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.1)
Using activerecord (4.0.2)
Using bcrypt-ruby (3.1.2)
Using orm_adapter (0.5.0)
Using thor (0.18.1)
Using railties (4.0.2)
Using warden (1.2.3)
Using devise (3.2.2)
Using bundler (1.5.2)
Using hike (1.2.3)
Using tilt (1.4.1)
Using sprockets (2.10.1)
Using sprockets-rails (2.0.1)
Using rails (4.0.2)
Was it helpful?

Solution

So I figured it out that engines (possibly just --mountable) do not include jquery to do things like :delete or :post so my fix was to include jquery-rails

engine.gemspec

+ s.add_dependency "jquery-rails"

app/assets/javascripts/engine/application.js

+//= require jquery
+//= require jquery_ujs
+//= require_tree .

OTHER TIPS

Same problem here. I just add:

#layouts/application.html.haml

= javascript_include_tag "application"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top