Skip to content

Instantly share code, notes, and snippets.

View JuarezLustosa's full-sized avatar
🏠
Working from home

Juarez Lustosa JuarezLustosa

🏠
Working from home
View GitHub Profile
@JuarezLustosa
JuarezLustosa / abilities.rb
Created September 16, 2012 13:34 — forked from ryanb/abilities.rb
How you can break up large Ability class in CanCan
module Abilities
def self.ability_for(user)
if user.admin?
AdminAbility.new(user)
else user
MemberAbility.new(user)
else
GuestAbility.new
end
end
class Payment < ActiveRecord::Base
def self.filtered(restrictions)
PaymentFilter.new(self.scoped).restrict(restrictions)
end
def self.year(year)
where(:year => year)
end
def self.person_id(person_id)