if_attribute is not ?

9 views
Skip to first unread message

matthias.nitsch

unread,
Nov 8, 2009, 1:10:52 PM11/8/09
to declarative_authorization
Hi,

i try to setup the use-case that a user can rate a feedback, if he has
not written it by itself. So I need something like

if_attribute :user => is not {user}

So I tried if_attribute :user => is {!user} but that doesn't work for
me.

Does anybody has a hint how I can do this?

Thanks in advance
Matthias

Jeremy Durham

unread,
Nov 8, 2009, 1:13:58 PM11/8/09
to declarative_...@googlegroups.com
Hi,

I think you may want if_attribute :user => is_not { user }

Hope that helps,
Jeremy

Matthias Nitsch

unread,
Nov 8, 2009, 1:16:05 PM11/8/09
to declarative_...@googlegroups.com
Hi Jeremy,

that doesn't work. with this you also can rate your own feedbacks :(

Jeremy Durham

unread,
Nov 8, 2009, 2:38:16 PM11/8/09
to declarative_...@googlegroups.com
Hi,

You may also want to try if_attribute :user_id => is_not { user.id }, if your feedbacks table has a user_id column. In authorization.rb (inside of declarative auth), there's a method called "validate?" in the Attribute class. I *think* this is where the code in question is evaluated. There's a case statement for :is_not, and you may try dropping a debugger or puts in there to see the value of attr_value and evaluated.

Hope that helps,
Jeremy
Reply all
Reply to author
Forward
0 new messages