Closed swistaczek closed 9 years ago
@swistaczek I'm not sure what you are trying to achieve, could you re-state your question?
@james2m in my app User could have role like 'admin' or 'moderator', this role match users action privalages for whole application, but I have also separate context (partner section and namespace) where user could have role like 'owner' or 'employee' and for example I would like to restrict User that is Employee for Partner to only view (action show) clients.
I store User-Partner relation in join model (id, user_id, partner_id, role [employee/owner]). I would like to add this separate context to before_filter for my Partner namespace base controller (other partners controllers inherit from base). Using only cancan I think I would define Ability controller with initialize method accepting 2 params (user model and partner role) and then judge what user should be able to do or what not. How to achive this with cancard?
@swistaczek firstly, sorry it's been a long wait. I've been on the road.
From what you describe everything you are trying to achieve is possible with straight cancan by referencing the join model attributes.
I assume this is all working now, but let me know if you need anything clarifying. If I don't hear anything I'll assume I'm good to close this.
Hello, First of all I would like to say thank you for great and well tested open source project. I have trouble with getting out of my problem so I decided to ask for help. Currently I am trying to make system with couple separate interfaces but with one User model. There is Admin, Partner and User interface. User could have many global roles (cancard fit there very good) but User could have many roles as PartnerUser (model which contains relation user_id, partner_id, role). I dont know how to set up before_filter in my Partner base namespace to add this separate context (role of user for selected partner).
Please checkout my relations:
Partner base controller
Thanks in advantage for any suggestions :). Have a nice day!