Frexuz
Frexuz

Reputation: 4933

Rails 3 and Devise - Sign out not working after converting app to Rails 3

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:

Upvotes: 3

Views: 2523

Answers (1)

Can Berk G&#252;der
Can Berk G&#252;der

Reputation: 113280

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 :users comes before resources :users in routes.rb. What seems to be the cause is, unless there'a typo in the question, that there's no comma after destroy_user_session_path. :method => :delete will be interpreted as a parameter to destroy_user_session_path unless there's a comma.

Also, make sure you're including jquery and jquery_ujs in application.js, as these are required for :method => :delete to work.

Upvotes: 4

Related Questions