Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7567633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:42:48+00:00 2026-05-30T14:42:48+00:00

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

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:42:49+00:00Added an answer on May 30, 2026 at 2:42 pm

    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!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My rails app has two pages based on two controllers/ views/ models..both controllers use
I am using Devise in a rail app. I have two models : User
I have a simple user registration page in my rails app that has two
I have RailsAdmin running for my Rails 3 app which has two models -
I have a Rails 2.3.11 app which has two key Models: Activity Transaction Live
I have a rails app that has two models one is vender and the
I have a rails app with two models, visits and users. A visit has
My Rails app has some pages which are SSL-required and others which are SSL-optional.
I'm writing a Rails app in which I have two models: a Machine model
I currently have a Rails 3.0.10 app and I made two models with simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.