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

  • Home
  • SEARCH
  • 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 9067203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:53:19+00:00 2026-06-16T16:53:19+00:00

I have two kinds of users: Admin and Worker. each user has role_ids: if

  • 0

I have two kinds of users: Admin and Worker.

each user has role_ids: if user.role_ids = [1], the user is Admin. if user.role_ids = [2], the user is Worker.

After the sign_up/sign_in, I want to redirect him by his role_ids:

if his kind is Admin, redirect him to: localhost:3000/tasksadmins.

if his kind is Worker, redirect him to: localhost:3000/workers.

this is my routes.rb:

devise_for :users do get '/users/sign_out' => 'devise/sessions#destroy' end

resources :tasksadmins

resources :workers

root to: "workers#index"

I think I have to do something like:

if current_user.role_ids == [2]
   root to: "workers#index"
else
   root to: "tasksadmins#index"
end

but current_user is not defined in the routes.

Any help appreciated!

  • 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-16T16:53:20+00:00Added an answer on June 16, 2026 at 4:53 pm

    You can override Devise’s RegistrationsController and modify the method after_sign_in_path_for according to your needs:

    def after_sign_in_path_for(resource_or_scope)
      if resource_or_scope.is_a?(User)
        return admins_path if resource_or_scope.admin?
        workers_path
      else
        super
      end
    end
    

    Hope this helps!

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

Sidebar

Related Questions

I have two kinds of users: Workers and Admins. I have a table of
I have a form, which allows the user to change dependencies between two kinds
I'm working on an app where a user can have one of two kinds
I have two relational tables: the Profiles table which contains 3 kinds of user
I have got two models, User and Event. I need two kind of relationship
Is this possible to have two (or more) different kinds of cells to be
I am using devise with two separate models for User and Admin. I wanted
This is better explained in: http://jsfiddle.net/tRBaV/1/ I have two kinds of entities: containers and
I have two models that has a manytomany relationship with a 'through' table in
I am developing an authentication system in CakePHP. I have two kind of users;

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.