class Ability
  include CanCan::Ability

  def initialize(person)

    # person
    can :update, person
    can :update, Person.undeleted, family: person.family if person.adult?
    can :manage, Person if person.admin?(:edit_profiles)

    # family
    can :update, person.family if person.adult?
    can :manage, Family if person.admin?(:edit_profiles)

    # group
    can [:update, :destroy], Group, memberships: {person: person, admin: true}
    can :manage, Group if person.admin?(:manage_groups)

    # album
    can [:update, :destroy], Album, person: person
    can :manage, Album if person.admin?(:manage_pictures)

  end
end

class Ability
  include CanCan::Ability

  def initialize(person)

    # person
    can :update, person
    can :update, Person, family: person.family, deleted: false if person.adult?
    can :manage, Person if person.admin?(:edit_profiles)

    # family
    can :update, person.family if person.adult?
    can :manage, Family if person.admin?(:edit_profiles)

    # group
    can [:update, :destroy], Group, memberships: {person: person, admin: true}
    can :manage, Group if person.admin?(:manage_groups)

    # album
    can [:update, :destroy], Album, person: person
    can :manage, Album if person.admin?(:manage_pictures)

  end
end

Speed up Ability definition on person by not using scope.
Speed up Ability definition on person by not using scope.

I'm not sure why using the 'undeleted' scope was so slow here. It seems
to add about 1-2 seconds every time it is called -- perhaps it is
querying *all* undeleted Persons in order to determine if any of them
match the conditions in the third parameter?
