Skip to main content

CanCanCan: Defining Abilities

General • Asked by Sascha M.

I'm using the CanCanCan gem. According to the documentation you can define abilities. That is working for me. What I want to do is to limit the access to records, that contain a value. Something like:

"can :crud, Order, :brand == nil"

is not working

A User should only be allowed to see the record, if the brand-column of the Order table is empty. As my example doesn't work apparently.. How would you do it?


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.