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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:05:09+00:00 2026-05-15T00:05:09+00:00

I have a system where I need to login three user types: customers, companies,

  • 0

I have a system where I need to login three user types: customers, companies, and vendors from one login form on the home page.

I have created one User table that works according to AuthLogic’s example app at http://github.com/binarylogic/authlogic_example. I have added a field called “User Type” that currently contains either ‘Customer’, ‘Company’, or ‘Vendor’.

Note: each user type contains many disparate fields so I’m not sure if Single Table Inheritance is the best way to go (would welcome corrections if this conclusion is invalid).

Is this a polymorphic association where each of the three types is ‘tagged’ with a User record? How should my models look so I have the right relationships between my User table and my user types Customer, Company, Vendor?

Thanks very much!

——UPDATE——

Current setup:

#User model
class User < ActiveRecord::Base
  acts_as_authentic
  belongs_to :authenticable, :polymorphic => true
end

#Customer model (Company and Vendor models are similar)
class Customer < ActiveRecord::Base
  has_many :users, :as => :authenticable
  acts_as_authentic
end

Is this a valid way to set them up?

  • 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-15T00:05:10+00:00Added an answer on May 15, 2026 at 12:05 am

    This is what it sounds like you are trying to do:

    You have users that can be in one of three groups. If that isn’t quite right a little clarification would help.

    Since AuthLogic only cares about it’s special fields, making and using other fields in your user model is no biggy.

    Each user might be made up something like this:

    #The Authlogic Fields
    t.string :username,          :null => false
    t.string :crypted_password,  :null => false
    t.string :password_salt,     :null => false
    t.string :persistence_token, :null => false
    
    #Your field to identify user type
    t.integer :user_type
    
    #If your user is a customer, you would populate these fields
    t.integer :customer_name
    ...
    
    #If your user is a company, you would populate these fields
    t.integer :company_name
    ...
    
    #If your user is a vendor, you would populate these fields
    t.integer :vendor_name
    ...
    

    I’m not sure what you mean by “single table inheritance” but if you want to keep information about a vendor in a table separate from the users table (really no reason to unless you are REALLY concerned about performance) you can just link up your models like this:

    class User < ActiveRecord::Base
      has_many :customers, :companies, :vendors
    end
    
    class Customer < ActiveRecord::Base
      belongs_to :user
    end
    
    class Company < ActiveRecord::Base
      belongs_to :user
    end
    
    class Vendor < ActiveRecord::Base
      belongs_to :user
    end
    

    In this case, since a user would have no associations to 2 of the 3 user types, you are pushed into using the has_many association which works nicely with the 0 association case. You would just have to do some checks in your code to make sure you don’t double up.

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

Sidebar

Related Questions

I need to create a message box for user login system. Now I have
I have a form MyForm : System.Windows.Forms.Form {} and I need to call Site.GetService(..)
I need to archive data from a CRM system. Does anyone have any idea
I have a timeclock system where i need to print a report for each
I need suggestion about YAMI library . I have a system which receives Json
I have an HTML help system that I need to convert to SharePoint. The
I am implementing a system where I need real-time updates. I have been looking
I need to implement a system where I have 5 forms. An agent then
I have a PMS(Pantone Matching System) color value. I need to find the corresponding
I have a web based (perl/MySQL) CRM system, and I need a section for

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.