Skip to content

Instantly share code, notes, and snippets.

@kolo
Created March 24, 2011 18:35
Show Gist options
  • Save kolo/885588 to your computer and use it in GitHub Desktop.
Save kolo/885588 to your computer and use it in GitHub Desktop.
# -*- 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