Skip to content

Instantly share code, notes, and snippets.

@jesscanady
Created October 11, 2011 17:58
Show Gist options
  • Save jesscanady/1278850 to your computer and use it in GitHub Desktop.
Save jesscanady/1278850 to your computer and use it in GitHub Desktop.
Completely untested legacy bitfield-based role system fixer.
alias_attribute :administrator :IsAdministrator
alias_attribute :consumer :IsConsumer
# etc...
# now you can do checks like:
if @user.administrator?
# and if you need .role:
def role
case self
when administrator?
"administrator"
when consumer?
"consumer"
# etc...
end
end
n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment