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 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

In my project I have to create some temp files in an USB device,
I have a Rails application for which I use devise to authenticate my users
I'm developing a Linux driver loadable module and I have to use another device
I'd like to use a virtual machine like NekoVM into a small device but
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
I use Firebug and the Mozilla JS console heavily, but every now and then
I'm starting a new project and I'm trying to figure out what technologies I
I'm working on a new project that I plan to keep in a git
I want to store some data from structures like this: class Project { ChildA
I've recently started a new web development project for an embedded device and wanted

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.