Created
March 24, 2011 18:35
-
-
Save kolo/885588 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
# -*- coding: utf-8 -*- | |
class Ability | |
include CanCan::Ability | |
def initialize(user) | |
# | |
# Events | |
# | |
can :update, Event do |event| | |
event.user == user || user.admin? | |
end | |
can :read, Plan, Plan.accessible_by_user(user) | |
# Блок выключен дабы поддежривалось Plan.accessible_by | |
# https://github.com/ryanb/cancan/wiki/Fetching-Records | |
# do |plan| | |
# plan.access_level=='public' or | |
# plan.user == user or | |
# plan.is_invited?(user) or | |
# (plan.access_level=='friend' and user.is_a_friend?(owner)) | |
# end | |
can :update, Plan, :user_id=>user.id | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment