Sha256: 931605bc35a908c863bfd4e4fd6a55e434ec123c696d924de90fdbb564cddeb5

Contents?: true

Size: 1.69 KB

Versions: 3

Compression:

Stored size: 1.69 KB

Contents

class Person < ActiveRecord::Base
  acts_as_authentic do |c|
    c.login_field :email
    c.merge_validates_uniqueness_of_email_field_options( :if => :skip_uniquess_of_email? )
    c.crypto_provider = Authlogic::CryptoProviders::BCrypt
  end
  acts_as_tagger

  def self.find_by_login_or_email(login)
   find_by_email(login)
  end

  has_and_belongs_to_many_attachments
  has_one :avatar,
    :dependent => :destroy
  has_one :address,
    :dependent => :destroy
  accepts_nested_attributes_for :address
  accepts_nested_attributes_for :avatar, :reject_if => proc { |attributes| attributes['uploaded_data'].blank? }

  validates_presence_of :lastname, :if => :skip_presence_of_lastname?
  validates_presence_of :firstname, :if => :skip_presence_of_firstname?

  # prevents a user from submitting a crafted form that bypasses activation
  # anything else you want your user to change should be added here.
  attr_accessible :lastname, :firstname, :email, :password, :password_confirmation,
    :civility, :country_id, :birthday, :phone, :other_phone, :email_confirmation,
    :avatar_attributes, :lang, :time_zone, :address_attributes

  define_index do
    indexes firstname, :sortable => true
    indexes lastname, :sortable => true
    indexes email, :sortable => true
    set_property :delta => true
  end

  def fullname
    "#{lastname} #{firstname}"
  end

  # Disactivates the user in the database.
  def disactivate
    update_attribute(:active, false)
  end

  # Activates the user in the database.
  def activate
    update_attribute(:active, true)
  end

  protected

  def skip_uniquess_of_email?
    true
  end

  def skip_presence_of_lastname?
    true
  end

  def skip_presence_of_firstname?
    true
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
forgeos_core-1.9.4 app/models/person.rb
forgeos_core-1.9.3 app/models/person.rb
forgeos_core-1.9.2 app/models/person.rb