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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:43:49+00:00 2026-05-27T08:43:49+00:00

If there a People model, how can I setup a polymorphic association of Users

  • 0

If there a People model, how can I setup a polymorphic association of Users and Customer?

For example, a Person could act as an User or as a Customer. People could be a User( extra columns: username, password), or it could be a Customer(no extra columns).

I’m trying to set this up so

  1. I won’t have a separate Users table and Customers table
  2. I don’t want to have a People table with a lot of empty username and password columns
  • 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-27T08:43:50+00:00Added an answer on May 27, 2026 at 8:43 am

    I agree with moo-juice, the correct approach would be people + roles. here’s a concrete example:

    class Person < ActiveRecord::Base
      has_many :roles, :through => :roles_people
      #columns would be username, password, etc
    end
    
    class Role < ActiveRecord::Base
      has_many :people, :through > :roles_people
      #a column of role_type would be required here and the values of such would be Customer, User, etc.  in this class you will put logic that is needed to execute the functions of the role
    end
    
    class RolesPerson < ActiveRecord::Base
       belongs_to :person
       belongs_to :role
       #this is a join model for a many-to-many relationship. you can store info in here about when a person acquired a certain role, etc.
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright all you wonderful people out there; In my user interface I am building
Suppose (for lack of better example) I have a model Person and another model
I'm seeing blog posts where people mention deprecated methods in rails3, for example model.errors.on
I have a person model and a quotes model. Each person can have many
I have a User model, Person model and Company model. a User has many
If there are any language designers out there (or people simply in the know),
There are several people about (myself being one of them) who have been developing
For people out there using Haxe , what makes it useful for you? Reading
There are some people in my office who insist on using cute stationery and
There are a lot of sites out there that teach people how to build

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.