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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:09:59+00:00 2026-05-22T13:09:59+00:00

I use Devise in my new project,but I have some problems in roles. There

  • 0

I use Devise in my new project,but I have some problems in roles.

There are two kinds of user in my project,but these two kinds of user have deferent data structure(very different).

I Know Devise supports roles,but how should I deal with the deferent user data structure?

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-22T13:10:00+00:00Added an answer on May 22, 2026 at 1:10 pm

    Devise documentation states that you can have as many Roles with different models as you want (configuring multiple models)

    You just set up the other model as you did with the first one and then add to routes.rb

    devise_for :admins
    

    And then you can use inside your controllers and views:

    # Inside your protected controller
    before_filter :authenticate_admin!
    
    # Inside your controllers and views
    admin_signed_in?
    current_admin
    admin_session
    

    The main question is how to let both of these accounts access the same controller (if it is applicable to your case), because of the two before_filters the first would always redirect to login page, if that is not the logged-in role (say :admin). You would probably have to implement a custom before_filter to validate the session against two roles simultaneously.

    You could probably work around this with custom routes for these roles. E.g /admin/projects and /user/projects. In that case the authenticate method could be helpful.

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

Sidebar

Related Questions

I have two models User and Admin(with RailsAdmin) that use Devise. I sign in
I'm using rails_admin which use devise. Some words still displays in english. I have
I'm currently trying to use Devise 1.1.pre3 as authentication in my upcoming project, but
I currently use Devise for user registration/authentication in a Rails project. When a user
I'm new to android. I have some java knowledge (not extensive), and I've done
In my project I have to create some temp files in an USB device,
I am trying to create a Unity 3D new Project. But i am not
My new project is targeting an embedded ARM processor. I have a build system
I'm trying to use a Notification control in a smart device C# project, but
This is my first time to use SharpPcap library. I created new project with

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.