Sha256: 77e1815c574d8a0c85fa25ee37300b55cadf3e65d45f562d0eed131046193202
Contents?: true
Size: 982 Bytes
Versions: 4
Compression:
Stored size: 982 Bytes
Contents
module Adminpanel class User < ActiveRecord::Base attr_accessible :email, :name, :password, :password_confirmation has_secure_password #name validations validates_presence_of :name #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
4 entries across 4 versions & 1 rubygems