2

UPDATE: /* I was able to fix the problem by setting up the asset pipeline as described in Railscasts #282*/

I am using Devise for authentication in my app. It was working fine until I added the gem Rails_admin. I also moved to Rails 3.1 in the process so perhaps the problem is with the move to 3.1.

On signing out I get:

"Couldn't find User with id=sign_out"

It traces back to the users_controller's show action and in the params: {"id"=>"sign_out"}

The sign out link is in the application layout:

<%= link_to 'User Sign Out', destroy_user_session_path, :method => :delete %>

The corresponding route:

destroy_user_session DELETE /users/sign_out(.:format)  {:action=>"destroy", :controller=>"devise/sessions"}

This problem seems similar to: Problem Signing Out with Devise on my App except that I am specifying the delete method.

Follow on. . found this method in Devise:

  def after_sign_out_path_for(resource_or_scope)
    root_path
  end

Could anyone tell me how to dig further? I.e. how to find 'resource_or_scope'? The root_path looks fine in the routes.

Here's my routes.rb:

Notebook::Application.routes.draw do

  mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'

  devise_for :owners

  match '/user' => 'users#dashboard', :as => :user_root
  match '/customer' => 'customers#dashboard', :as => :customer_root

  match 'users/dashboard' => 'users#dashboard'

  match 'customers/dashboard' => 'customers#dashboard'


  devise_for :users

  devise_for :customers

  resources :users

  resources :customers, :only => [:index, :show, :edit, :update, :destroy]

  root :to => 'misc#landing'
end
Community
  • 1
  • 1
John
  • 13,125
  • 14
  • 52
  • 73
  • Are you using a custom sessions controller? Also let's take a look at your `routes.rb` file so we can see what is going on? – janders223 Oct 06 '11 at 11:30
  • Not using a custom controller. I think one fix, though I don't think it's preferable, would be to modify the sessions controller so that the redirect doesn't go to after_sign_out_path. Added my routes.rb above. – John Oct 06 '11 at 12:47
  • The `after_sign_out_path` is just a callback for after the session is destroyed, and won't get you what you want. I have never used the rails_admin gem, and will have to dig more into it before I can know more of what is going on. – janders223 Oct 06 '11 at 13:29
  • Your problem seems similar enough to a few I've ran into before, including my own problem. Check out my answer in this question [http://stackoverflow.com/questions/6808465/rails-devise-no-route-matches-logout/7099462#7099462]. Hope this helps! – vich Oct 12 '11 at 22:02
  • I was able to fix the problem by setting up the asset pipeline as described in Railscast #282. – John Oct 14 '11 at 16:36

0 Answers0