Created
March 30, 2010 16:31
-
-
Save jackdempsey/349266 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ability | |
include CanCan::Ability | |
def initialize(user) | |
can [:read, :sort], Feature do |feature| | |
# below is turning into an idiom for me, one I sometimes forget about. | |
# thoughts on a better way to expose the "if we have an instance, use this check, else grant access to read/sort the Feature class" | |
(feature && feature.project.has_user?(user)) || true | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment