app/models/users/user.rb
def has_role?(role, unit = nil)
    if unit
      unit = Unit.find(unit) unless unit.is_a?(Unit)
      roles.for(unit.id).collect(&:to_sym).include?(role.to_sym) || roles.for(nil).collect(&:to_sym).include?(role.to_sym)
    else
      roles.collect(&:to_sym).include?(role.to_sym)
    end
  end
# Returns true if this user's roles include the requested role. This can be passed as a symbol or string.
# If the user must have the role assigned for a specific unit, specify the unit object or ID as the second parameter.
# Note that "global" roles (i.e., roles with no unit assigned) will always return true regardless of the
# unit that is passed.
Returns true if this user's roles include the requested role. This can be passed as a symbol or string.
If the user must have the role assigned for a specific unit, specify the unit object or ID as the second parameter.
Note that "global" roles  will always return true regardless of the
unit that is passed.
Returns true if this user ' s roles include the requested role . This can be passed as a symbol or string . If the user must have the role assigned for a specific unit specify the unit object or ID as the second parameter . Note that " global " roles will always return true regardless of the unit that is passed .
def has_role?(role, unit = nil)
    if unit
      unit = Unit.find(unit) unless unit.is_a?(Unit)
      roles.for(unit.id).collect(&:to_sym).include?(role.to_sym) || roles.for(nil).collect(&:to_sym).include?(role.to_sym)
    else
      roles.collect(&:to_sym).include?(role.to_sym)
    end
  end
def has_role? ( role , unit = nil ) if unit unit = Unit . find ( unit ) unless unit . is_a? ( Unit ) roles . for ( unit . id ) . collect ( & :to_sym ) . include? ( role . to_sym ) || roles . for ( nil ) . collect ( & :to_sym ) . include? ( role . to_sym ) else roles . collect ( & :to_sym ) . include? ( role . to_sym ) end end
Returns true if this user's roles include the requested role.
Returns true if this user ' s roles include the requested role .
role
unit