Best way to manage different settings model for different user roles?

I'm looking for some input on the best way to support user settings when dealing with different user roles.

I have a Users model and in that have all the 'required' fields for a user. A given user can have a different role as well. Each role has vastly different misc settings we need to keep track of for that role.

Curious what would be the best way to keep all users in the Users model/table but still manage all the various role settings. Would it be best just to create separate models/tables for each role and just prefix it with the role name (i.e: role1_settings, role2_settings, role3_settings etc) and glue them together with some AR/Association magic?

Only issue I see is if a user has multiple roles, though I might have to enforce 1 role per user. Anyways, thanks for any thoughts in advance.

I'm looking for some input on the best way to support user settings when dealing with different user roles.

I have a Users model and in that have all the 'required' fields for a user. A given user can have a different role as well. Each role has vastly different misc settings we need to keep track of for that role.

Curious what would be the best way to keep all users in the Users model/table but still manage all the various role settings. Would it be best just to create separate models/tables for each role and just prefix it with the role name (i.e: role1_settings, role2_settings, role3_settings etc) and glue them together with some AR/Association magic?

Only issue I see is if a user has multiple roles, though I might have to enforce 1 role per user. Anyways, thanks for any thoughts in advance.

seems like you would probably want to create a role_settings table with

id role_id setting_name

and a user_role_settings table

id user_id role_setting_id value

then you can create your user, assign them some roles using a habtm relationship between the users and roles tables

Roles can then take any number of settings, via the role_settings table (belongs_to/has_many relationship), which means you're never limited to the number of settings a role can take

You can then store the user's settings in the user_role_settings table, which would be governed by the roles that a user had assigned. (if needed, you could add role_id in there to speed up joins)

If you wanted to store enumerations for a role_setting you could make another table role_setting_values with role_id / value.

I remember setting up something like this in ASP and it was a bit of a headache but in rails it should be child's play.

If you need a good start with users/role based authentication, get hold of restful_authentication and add acl_system2 plugin which will give you simple role management. The rest of the above would give you the power to leverage bespoke settings for roles and let your users manage them.

Hope this assists?

Might want to check out the acl_system2 plugin.