Skip to content

Instantly share code, notes, and snippets.

@johncblandii
Created February 8, 2013 23:19
Show Gist options
  • Save johncblandii/4742767 to your computer and use it in GitHub Desktop.
Save johncblandii/4742767 to your computer and use it in GitHub Desktop.
Getting a list of available user types by a users type
class User
def user_type
"system_admin"
end
def self.user_types_for user
types = []
case user.user_type
when "system_admin"
types << "system_admin"
types << "admin"
types << "case_worker"
types << "staff"
types << "student"
when "admin"
types << "admin"
types << "case_worker"
types << "staff"
types << "student"
when "case_worker"
types << "student"
when "staff"
types << "case_worker"
types << "student"
when "student"
types << "student"
end
types
end
end
User.user_types_for User.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment