8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/date_book/concerns/ability.rb', line 8
def initialize_date_book(user)
alias_action :index, :show, :popover, to: :read
can :read, [Calendar, Event]
unless user.new_record?
my_calendar_ids = Calendar.with_role(:owner, user).ids
can :create, Calendar
can :manage, Calendar, id: my_calendar_ids
can :manage, Event, calendar_id: my_calendar_ids
can :manage, Event, id: Event.with_role(:owner, user).ids
end
can :manage, :all if user.has_role? :admin
end
|