I am creating application which requires User management of various levels for authorization of different level of users. I want several models: Admin_user Project Manager Company Clients Account : have many users of all level.Every user have account. See below the relations between our models: 1. Admin_user : have many project managers and can give rights to project manager.It can add and delete Project managers.Admin can access or manage any level of this application i.e. Its a SUPER USER. 2.Project manager : have many companies.It can create and delete many companies. Project Manager can also add new project manager if Admin_user give right to him to create new project manager.its all depends on Admin_user to give or take rights from PM. 3. Companies : can create and delete many client_users but cannot create any company in th same level.Company also start or stop rights of client. 4.Client :can have account login and use services provided by company nothing more than that. This is my model Association. But i m confused what can i make first a Account model or a Admin_user model. Thanks -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 13 February 2012 07:08, Anurag Sachan <anuragsachan07-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am creating application which requires User management of various > levels for authorization of different level of users. > I want several models: > Admin_user > Project Manager > Company > Clients > Account : have many users of all level.Every user have account. > See below the relations between our models: > 1. Admin_user : have many project managers and can give rights to > project manager.It can add and delete Project managers.Admin can > access or manage any level of this application i.e. Its a SUPER USER. > 2.Project manager : have many companies.It can create and delete many > companies. Project Manager can also add new project manager if > Admin_user give right to him to create new project manager.its all > depends on Admin_user to give or take rights from PM. > 3. Companies : can create and delete many client_users but cannot > create any company in th same level.Company also start or stop rights > of client. > 4.Client :can have account login and use services provided by company > nothing more than that. > This is my model Association. But i m confused what can i make first > a > Account model or a Admin_user model.I think you may be going about this the wrong way. Instead of having many different models for the user types have one model for all users and assign roles to give them different permissions. Have a look at the cancan gem. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
CanCan would be simple to achieve what you want.Install cancan gem and define Ability.rb in models Sample Abillity.rb might look like this. class Ability include CanCan::Ability def initialize(user) # Define abilities for the passed in user here. For example: # user ||= User.new # guest user (not logged in) if (user.role == ''admin'') can :manage, :all else can :read, :all end end end Thanks, Siva On 2/13/2012 3:00 PM, Colin Law wrote:> On 13 February 2012 07:08, Anurag Sachan<anuragsachan07-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I am creating application which requires User management of various >> levels for authorization of different level of users. >> I want several models: >> Admin_user >> Project Manager >> Company >> Clients >> Account : have many users of all level.Every user have account. >> See below the relations between our models: >> 1. Admin_user : have many project managers and can give rights to >> project manager.It can add and delete Project managers.Admin can >> access or manage any level of this application i.e. Its a SUPER USER. >> 2.Project manager : have many companies.It can create and delete many >> companies. Project Manager can also add new project manager if >> Admin_user give right to him to create new project manager.its all >> depends on Admin_user to give or take rights from PM. >> 3. Companies : can create and delete many client_users but cannot >> create any company in th same level.Company also start or stop rights >> of client. >> 4.Client :can have account login and use services provided by company >> nothing more than that. >> This is my model Association. But i m confused what can i make first >> a >> Account model or a Admin_user model. > I think you may be going about this the wrong way. Instead of having > many different models for the user types have one model for all users > and assign roles to give them different permissions. Have a look at > the cancan gem. > > Colin >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.