1

This is my first post on Stack Overflow. I am trying to build a system that authenticates three types of user with completely different site experiences: Customers, Employers, and Vendors.

I'm thinking of using a polymorphic 'User' table (using AuthLogic) with username, password, and user_type (+ AuthLogic's other required fields). If this is a good way to go, how do I set this up so after authenticating an user_id with a user_type the standard way, I can direct the user to the page that's right for them?

Thanks.

2
  • I would also consider checking out the cancan plugin: github.com/ryanb/cancan Commented May 16, 2010 at 13:29
  • I certainly will Zachary, thank you! Commented May 16, 2010 at 16:28

2 Answers 2

1

I'd consider STI in this case. Then each can authenticate as a normal user, but easily branch into their own specific behavior when needed. You may need to do some work with your routes to make everything line up, however.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks very much. Can you give me some detail on how the routes would work?
Just setting up STI, it's going to assume that each type of user is a completely different type of resource, with its own controller and everything, so if don't want that (e.g. you want to use the users controller for all user types), you would do something like: map.resources :customers, :employers, :vendors, :controller => :users
0

sscirrus, are there any relationships between them (Customers, Employers, and Vendors) at all? I've got a similar case but with a one-to-many relationship.

1 Comment

Hi Sergio, Yes, there are relationships between all these tables, as follows (I'll only give the one half, obviously the other direction of these relationships are specified in the models): Employer has_many :vendors, Employer has_many :projects, Project has_many :customers, :through => :matching.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.