This post originated from an RSS feed registered with Ruby Buzz
by Jan Lelis.
Original Post: Troubleshooting a aegis-permission problem
Feed Title: rbJ*_*L.net
Feed URL: http://feeds.feedburner.com/rbJL
Feed Description: Hi, I am a fan of Ruby and like to explore it and the world around ;).
So I started this blog, where I am publishing code snippets, tutorials for beginners as well as general thoughts about Ruby, the web or programming in general.
In my current Rails project, I use the aegis gem for rights management. And I almost got mad, wondering, why it wouldn’t work..\nHere is the code I had the problem with:
# in models/permission.rbpermission:access_photodo|user_or_group,photo|allow:userdouser_or_group.allowed_photos.first==photoendend
which was called like this (I know, it’s a little bit unDRY):
user.may_access_photo?(user,photo)
After some nerve-wracking debugging, I realized, that the first block parameter of the permission block is reserved for the “self”-user, the one on which you ask… Then, the second parameter is the first you want. I changed it to: