Sha256: 097789417cc8cdbea386c5a092284d67336b10f545355d5625352e167f55873c
Contents?: true
Size: 1 KB
Versions: 8
Compression:
Stored size: 1 KB
Contents
module Adminpanel class User < ActiveRecord::Base attr_accessible :email, :name, :password, :password_confirmation has_secure_password #name validations validates_presence_of :name validates_length_of :name, :maximum => 25 #password validations validates_confirmation_of :password validates_presence_of :password validates_length_of :password, :minimum => 6 #password_confirmation validations validates_presence_of :password_confirmation #email validations validates_presence_of :email validates_uniqueness_of :email VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates_format_of :email, :with => VALID_EMAIL_REGEX before_save{ email.downcase! } before_save :create_remember_token def has_role?(role_sym) roles.any? { |r| r.name.underscore.to_sym == role_sym } end private def create_remember_token self.remember_token = SecureRandom.base64.tr("+/", "-_") end end end
Version data entries
8 entries across 8 versions & 1 rubygems