Skip to content

Instantly share code, notes, and snippets.

@ckozus
Created October 29, 2014 14:02
Show Gist options
  • Save ckozus/5ec61c5359b8421e5317 to your computer and use it in GitHub Desktop.
Save ckozus/5ec61c5359b8421e5317 to your computer and use it in GitHub Desktop.
def self.get_superiors_of(user)
superiors = Array.new
return superiors if user.departament.nil?
case user.is_chief
when true
unless user.departament.parent.nil?
superiors = user.departament.parent.users.chiefs.to_a
end
when false
if user.departament.users.chiefs.to_a.count > 0
superiors = user.departament.users.chiefs.to_a
else
unless user.departament.parent.nil?
superiors = user.departament.parent.users.chiefs.to_a
end
end
end
superiors
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment