My routes
devise_for :users
devise_for :admin_users, ActiveAdmin::Devise.config #I have also tried removing this for any conflicts
resources :users
The sign out link. Routes to /users/sign_out just fine
<%= link_to "Logout", destroy_user_session_path, :method => :delete %>
Trying to sign out, gives me the error:
Couldn't find User with id=sign_out
If I then remove the resource :users, I get:
The action 'sign_out' could not be found for UsersController
What’s wrong? The exact same code worked with Rails 2.3.8 and the corresponding Devise version
Logging in etc. works fine.
My setup is:
- Ruby 1.9.2
- Rails 3.1.1.rc3
- Devise 1.4.8
First of all, using the same path for UsersController and Devise isn’t a great idea. I would suggest using a path like ‘/accounts’ for Devise.
But this probably isn’t the cause of your sign out problem, as
devise_for :userscomes beforeresources :usersin routes.rb. What seems to be the cause is, unless there’a typo in the question, that there’s no comma afterdestroy_user_session_path.:method => :deletewill be interpreted as a parameter todestroy_user_session_pathunless there’s a comma.Also, make sure you’re including jquery and jquery_ujs in application.js, as these are required for
:method => :deleteto work.