Question: My Rails 3.1 app has two user models: User and Admin. I'm using Devise.

My routes.rb contains 

```
root :to => "pages#welcome"

```

where users can login as a User or and Admin.

Once logged in, the root path should change. The root for Admins should be "admins#dashboard", the root for Users should be the current user's show page.

I'm having trouble working out how best to achieve this, and I have three questions.

1. How do I define resource specific roots. I feel that I should be
defining a 'user\_root\_path' and an "admin\_root\_path' but haven't been able to work out the
syntax for this in my routes file?
2. How to I pass in the current user's ID so that I can root to the user's show page?
3. How can I ensure that only a User or an Admin session can be active at any one
time, and that users cannot login as both simultaneously?

I would be very grateful for a pointer in the right direction, as this has got me stumped!

Thank you.

Answer: 
After a bit of digging, and some pointers from Mikhail, I managed to answer this myself.

In my routes.rb file I added the following:

```
root :to => "pages#welcome"

```

to define the root for unauthenticated users.

```
authenticated :admin do
    root :to => "dashboard#show"
end

```

to define the root for authenticated admins, and

```
match '/dashboard' => "dashboard#show", :as => :admin_root

```

to define the admin after login redirect and tidy up the path.

Thanks for all the repsonses!
pages#welcome<--- in this controller and action send params anonymous

Could you please try this in your application.rb

```
def after_sign_in_path_for(resource)
  if params[:anonymous].eql?("1") // mean user
    redirect_to user_root_path, :user_id => current_user.id
  else // mean administration
    redirect_to admin_root_path
  end
end

```

config user\_root\_path and admin\_root\_path to your destination you want in route.rb

Hope it will help.