Created
February 8, 2013 23:19
-
-
Save johncblandii/4742767 to your computer and use it in GitHub Desktop.
Getting a list of available user types by a users type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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