Created
May 13, 2012 07:56
-
-
Save ch1ago/2686830 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) | |
user ||= User.new # guest user | |
can :read, Band | |
can :create, Band do |band| | |
user.persisted? | |
end | |
can [:update, :destroy], Band do |band| | |
band.user == user.id | |
end | |
can :read, [Band, Song] | |
can :create, Song do |song| | |
song.band.user == user.id | |
end | |
can [:update, :destroy], Song do |song| | |
song.user == user | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment