Reputation: 40107
What is the best way to architect a Rails app to handle two distinct classes of users? For a marketplace there'll be Buyers and Sellers. There will be overlapping functionality in editing the profiles and such, but most the funcitonality will be distinct. Is the approach in the following post a good way to do it? I'm hoping to use RESTful Authentication.
Upvotes: 2
Views: 278
Reputation: 37133
You can also look at using a more fully-fledged authorisation plugin like:
Such a system provides you with a complete DSL for providing access to your application.
Upvotes: 0
Reputation: 9768
I'd keep the authentication separate from the user info and details. Have a UserAuth
object for auth and then a polymorphic association to a User
record. A Buyer and a Seller are then just subclasses of User, as long as you refer to them and not the UserAuth
objects all the rails helpers (render @user
to render either a _buyer
or a _seller
partial etc.) should work just fine.
Both buyer and seller can delegate generic stuff back down to the UserAuth instance.
Just a thought.
Upvotes: 1
Reputation: 199
You could just use one instance of RESTful Authentication and add a column to the Users table that would say which class a user was a part of. Then you can show certain links/pages only to users that match a particular class.
I use this method to have different user roles (admin, editor, regular user, etc.).
Upvotes: 0