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/

+2


source to share


3 answers


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.

+1


source


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.).

0


source


You can also see how to use the more complete authorization plugin, for example:

Such a system provides you with a complete DSL to provide access to your application.

0


source







All Articles