Marston A.
2008-Mar-09 20:22 UTC
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. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Craig White
2008-Mar-10 00:33 UTC
Re: ****[Rails] Best way to manage different settings model for different user roles?
On Sun, 2008-03-09 at 13:22 -0700, Marston A. wrote:> 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 ended up using a methodology suggested but not completely delineated in Rails Recipes where there are Rights, Roles and Users. Thus a User could have many Roles, and there are many Rights for each Role and thus the catch is that a User can only access methods that are specifically given to Rights via Roles that he is assigned to. Craig --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Wildtangent
2008-Mar-10 00:36 UTC
Re: Best way to manage different settings model for different user roles?
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? On Mar 9, 8:22 pm, "Marston A." <mars...-8Qo2DTIsO68RmelmmXo44Q@public.gmane.org> wrote:> 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.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
AndyV
2008-Mar-10 12:06 UTC
Re: Best way to manage different settings model for different user roles?
Might want to check out the acl_system2 plugin. On Mar 9, 4:22 pm, "Marston A." <mars...-8Qo2DTIsO68RmelmmXo44Q@public.gmane.org> wrote:> 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.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---