I agree with Marnen.  The easiest way would be to just add a role
field to the user model.

I wouldn't mess with inherited classes or associations for what you
are describing.

But if you do, you really should use inheritance, as Marnen
described.

The only other table that I might consider would a "domain-table"
called Roles (or anything you want).  It could start with simply
an :id field and a :name field.  This could later be expanded to
include more data.  Then in your user table you could define a field
for the role_id which could be set via the Role table.  The advantage
of this is that you get a central place to define all possible roles
within the database rather that in just your rails application.  This
would allow you to guarantee referential integrity in the database, so
that a user could not be made with an unintended role by bypassing
your rails app (at the mysql or psql prompts, for example).

Of course, the importance of an unintended role getting into the
database depends of your application setup.  If you blacklist
everything and only open up certain areas of the app by white-listing
roles, then the consequence is less severe.  Beware however, if you
whitelist everything and only blacklist based on the role.  This type
of setup might allow unrestricted access to an unintended role.  For
this reason, I tend to blacklist everything, and then whitelist based
on the role.

Andrew

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to