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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:10:37+00:00 2026-06-01T00:10:37+00:00

I want users#new and tasks#index to display as the root path URL, i.e. /

  • 0

I want users#new and tasks#index to display as the root path URL, i.e. / When a user logs in on the path users#new (set as root) they are redirected to tasks#index and URL does not change. Can this be done in the routes.rb file?

This is my routes.rb file:

Todo::Application.routes.draw do
  resources :sessions 
  resources :subscriptions
  resources :users
  resources :tasks do
    collection do
      post :sort
    end
  end
  root :to => "users#new"
  match "sessions#new" => "tasks#index"
  match "sessions#" => "tasks#index"
  • 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-06-01T00:10:38+00:00Added an answer on June 1, 2026 at 12:10 am

    I’m not sure I would actually do this,but assuming you map the root tasks#index, you could also use a before filter to render the sessions#new template when the user is not logged in:

    class TasksController < ApplicationController
    
      before_filter :authorize_access
    
      def authorize_access
        unless logged_in?
          render :template => 'sessions/new'
          return false  #I don't remember if you need this still or not
        end
      end
    
      def index
        @tasks = Task.all
      end
    
    end
    

    To be clear, when a user requests “/”, Rails will route this request to a single controller and action. You can map multiple paths to the same controller/action, but a single path is deterministic to a particular controller/action. IOW – it is not logically possible in routes to have a get request for any path, root or otherwise, go to more than one controller/action.

    Users don’t see a controller and action though, they see the result of what the action renders, usually based on some template, and that you can determine in the action (or a controller filter’s) logic, as I did above.

    You could also create a 3rd controller, a RootController, that contains the logic to display the list of tasks or a login page based on if the user is logged in.

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

Sidebar

Related Questions

I'm new to using SugarCRM. I want to have a users page that does
I want to give users the possibility to dynamically add new columns at the
I have such view that handles user registration. After creating new user i want
I have a webpage where I want the user to see a new image
I want to implement user stories in a new project where can i find
I want users to receive 'points' for completing various tasks in my application -
in VS2010 tfs , I want to add 5 new linked tasks (documentation, unit
I'm starting a new C# project that uses a database, but I want it
i want users can log in my website throw FB connect ON MOBILE but
I want users to enter a comma-delimited list of logins on the form, to

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.