Simpler way of solving Roles and Permission Problem
Query On Roles and Permission:
Admin ,Carer ,Care Manager ,All are the Fixed Roles .
Role "All" conditions has a different functionality - it means to read /write should be given to everyone irrespective of other roles.
For each role can have read or write permission.
I have solved this by creating a table cal开发者_开发技巧led Permission with fields Permission Name, section , admin , C ,CM ,All and store data 1 if "Read " and 2 if it is "Write" .
I tried with the intermediate table (HABTM) to connect role and permission .but the intermidiate table needs read and write option.
Tried with has_many :through functionality but the Role "All" functionality looks bit odd.
I would like to know is there any simpler way of achieving this ?**
I don't have a ton of time to writeup a great response (so I don't expect any credit) but I always use the padlock_authorization gem to do roles on my rails sites and and love it. It can degrade to handle a simple global role or complex model-based roles as well.
Other folks will have different libs they use; there a a good amount out there for Rails at this point.
Why reinvent the wheel ? http://railscasts.com/episodes/188-declarative-authorization
I have had great experience with using acl9 in conjunction with Authlogic. They work easily together, there also should be several example about using these two together.
精彩评论