Rails: Polymorphic User Table a good idea with AuthLogic?

Posted by sscirrus on Stack Overflow See other posts from Stack Overflow or by sscirrus
Published on 2010-05-26T03:48:39Z Indexed on 2010/05/26 4:11 UTC
Read the original article Hit count: 343

Hi everyone,

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!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about user