Possible Duplicate:
Different '/' root path for users depending if they are authenticated (using devise)
Active Admin authentication conflicting with User authentication
I recently upgraded to rails 3.1 and am using devise to authenticate my users.
I would like to set up my routes such, that when a user is not logged in, my root takes me to home#index, from where the user can click a log in link to go to the separate log in page, but when the user is already logged in, the root takes them to user#dashboard.
Actually, this functionality was already working in my application earlier, but after upgrading to rails 3,1 (and also installing active admin, which btw also uses devise), this has stopped working somewhere along the way and I am wondering if there is another way to go about this or maybe I need to update the syntax. This is what my routes file has at the moment
root :to => 'users#dashboard', :constraints => lambda {|r| r.env["warden"].authenticate? }
root :to => 'home#index'
get "/" => 'users#dashboard', :as => "user_root"
Right now it just always takes me to the home#index
UPDATE
It actually seems like I am getting this issue due to Active Admin and the fact that it uses Devise. Logging in to the active admin interface affects the behavior such that the app attempts to take every user to the dashboard if the active admin is logged in and every user to the home#index if active admin is logged out, both regardless of if the general user itself is logged in or not.
Does anyone know how to get Active Admin's logged in admin to not affect general user logged in. Active Admin already uses 'admin' as its users which are separate from my 'users' model.