Skip to content

Instantly share code, notes, and snippets.

@mrichman
Created May 11, 2009 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrichman/110147 to your computer and use it in GitHub Desktop.
Save mrichman/110147 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
ROLES = %w(admin user guest).freeze
acts_as_authentic
acts_as_authorization_subject
validates_presence_of :login, :email
belongs_to :creator, :class_name => "User"
attr_protected :creator
def role
ROLES.detect { |role| self.has_role?(role) }
end
def admin?
!!(role =~ /admin/)
end
def deliver_password_reset_instructions!
reset_perishable_token!
Notifier.deliver_password_reset_instructions(self)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment