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 7030111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:37:36+00:00 2026-05-28T00:37:36+00:00

I have a root_path on my Rails application that is not user-protected i.e. it’s

  • 0

I have a root_path on my Rails application that is not user-protected i.e. it’s a simple portal homepage, with a login form.

After the users log in, I’d like it to go to dashboard_path.

I’ve done this:

def signed_in_root_path(scope_or_resource)
  dashboard_path
end

This apparently should be used when an user signs in, and I don’t want it to go to the root_path, while still keeping the user going back to a previous page if it tries to hit a restricted area and it’s either timed out or not logged in.

i.e.:

restricted_page -> login -> restricted_page_but_logged_in

I don’t want to change this behavior, and that’s why I haven’t used after_sign_in_path, but want to redirect it if it’s on root_path, or any route that doesn’t require user authentication.

My problem is that this is not working. After signing in, I’m getting redirected back to root_path, which I believe is because of after_sign_in_path getting triggered before.

Is there any way to do this? Thanks!

Edit: This works the second time I log in, i.e. I go to root_path, log in, gets the flash message stating me that I’m logged in, and enter username and password again on the form on root_path. I successfully get redirected to dashboard_path. Still, not quite the behavior I want.

  • 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-28T00:37:37+00:00Added an answer on May 28, 2026 at 12:37 am

    Just a thought

    You can define two root url one for signed in url which will point to dashboard and second for non signed in users which will point to login page

    define different root url based on some constraints
    in routes.rb

    root url for signed in users

    constraints(AuthenticatedUser) do 
      root :to => "dashboard"
    end
    

    root url for non signed in users

    root :to=>"users/signin"
    

    then create class AuthenticatedUser in lib/authenticated_user.rb

    class AuthenticatedUser
      def self.matches?(request)
        user_signed_in?
      end
    end
    

    now if user is signed in root_url will point to dashboard else it will point to signin page

    Your can also create two roots using(did not tested it yet)

    root :to => "dashboard", :constraints => {user_signed_in?}
    root :to => "users/signin"
    

    more on constrains
    http://edgeguides.rubyonrails.org/routing.html#request-based-constraints

    Note

    The priority of url is based upon order of creation,
    first created -> highest priority resources

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

Sidebar

Related Questions

I have this application where I use Devise and, after login the user is
My Rails application have a User model and a Group model, where User belongs
I have recently created a new rails 3 application, using the code that I
I am on rails 2.3.5 and have the latest Ruby installed and my application
I have a Rails 3.1 application. I am deploying it via passenger to a
I have an application in Rails 2.3.11, with several bundled gems under APP_ROOT/vendor/gems .
I have an application running in rails 3.1 where a page displays embedded videos.
I have a rootPath that I trust and a relativePath that I don't. I
I am using a machine on which I do not have root access and
Motorola phones do not have Verisign/Thawte root certificates for code signing. They only embed

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.