Scheduling Two Types of Users in a Rails Application
What's the best way to create a Rails application to handle two different classes of users? There will be Buyers and Sellers for the market. Duplicate functions will be performed when editing profiles, but most functions will be different. Is the approach in the following article a good way to do this? I am hoping to use RESTful authentication.
http://www.imarichardson.com/2007/06/30/using-2-instances-of-restful-authentication-with-different-models/
I would keep authentication separate from user info and details. Have an object UserAuth
for auth and then a polymorphic record association User
. Buyer and Seller are just User subclasses, if you are referencing them and not objects UserAuth
all rail helpers ( render @user
for rendering a particle _buyer
or _seller
etc) should work fine.
Both the buyer and seller can delegate shared material back to the UserAuth instance.
Just a thought.
You can simply use one RESTful Authentication instance and add a column to the Users table that will tell you which class the user belongs to. Then you can only show certain links / pages to users who match a certain class.
I use this method to create different user roles (admin, editor, regular user, etc.).
You can also see how to use the more complete authorization plugin, for example:
- http://github.com/DocSavage/rails-authorization-plugin
- http://github.com/stffn/declarative_authorization
Such a system provides you with a complete DSL to provide access to your application.