ability.rb revision 7b025f9d9726413eb3f50ca2b39826e7eed816fb
class Ability
include CanCan::Ability
def initialize(user)
# Define abilities for the passed in user here.
user ||= User.new # guest user (not logged in)
if user.admin?
can { true }
elsif user.id
# Ontologies
can [:edit, :update, :destroy], Ontology do |subject|
subject.permission?(:owner, user)
end
# Team permissions
can [:create, :show, :index], Team
can [:edit, :update, :destroy], Team do |subject|
subject.admin?(user)
end
end
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
end
end