Sha256: b6f8230f8ca8a8c25ea9193785358532fd460607a2728d4edd4d42bc52e93f70

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 KB

Contents

class User < ActiveRecord::Base
  include ActiveModel::Validations

  attr_accessor :password_validator

  has_roles
  include ErpTechSvcs::Utils::CompassAccessNegotiator

  belongs_to :party

  attr_accessible :email, :password, :password_confirmation
  authenticates_with_sorcery!

  #password validations
  validates_confirmation_of :password, :message => "should match confirmation", :if => :password
  validates :password, :presence => true, :password_strength => true, :if => :password

  #email validations
  validates :email, :presence => {:message => 'Email cannot be blank'}, :uniqueness => true
  validates_format_of :email, :with => /\b[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}\z/

  #username validations
  validates :username, :presence => {:message => 'Username cannot be blank'}, :uniqueness => true

  #these two methods allow us to assign instance level attributes that are not persisted.  These are used for mailers
  def instance_attributes
    @instance_attrs.nil? ? {} : @instance_attrs
  end

  def add_instance_attribute(k,v)
    @instance_attrs = {} if @instance_attrs.nil?
    @instance_attrs[k] = v
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
erp_tech_svcs-3.0.10 app/models/user.rb
erp_tech_svcs-3.0.9 app/models/user.rb
erp_tech_svcs-3.0.8 app/models/user.rb
erp_tech_svcs-3.0.7 app/models/user.rb
erp_tech_svcs-3.0.6 app/models/user.rb
erp_tech_svcs-3.0.5 app/models/user.rb
erp_tech_svcs-3.0.4 app/models/user.rb
erp_tech_svcs-3.0.3 app/models/user.rb
erp_tech_svcs-3.0.2 app/models/user.rb
erp_tech_svcs-3.0.1 app/models/user.rb