The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Troubleshooting a aegis-permission problem

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jan Lelis

Posts: 136
Nickname: rbjl
Registered: Aug, 2009

Jan Lelis is an IT student from Dresden/Germany
Troubleshooting a aegis-permission problem Posted: Sep 9, 2009 2:04 PM
Reply to this message Reply

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.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jan Lelis
Latest Posts From rbJ*_*L.net

Advertisement

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.rb
permission :access_photo do |user_or_group,photo|
    allow :user do
      user_or_group.allowed_photos.first == photo
    end
  end

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:

:access_photo do |cur_user,user_or_group,photo|

CC-BY-SA (DE)

Read: Troubleshooting a aegis-permission problem

Topic: Visual Flex Component Layout Previous Topic   Next Topic Topic: Another Bout With Math::Pari

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use