Sha256: 2dd96a07ef6ec75e1924387c06ecf7d97fa36591cf6ee18262c65dfbdc22231d

Contents?: true

Size: 846 Bytes

Versions: 13

Compression:

Stored size: 846 Bytes

Contents

class Dorsale::CustomerVault::Event < ::Dorsale::ApplicationRecord
  self.table_name = :dorsale_customer_vault_events

  ACTIONS       = %w(create update comment)
  CONTACT_TYPES = %w(contact r1 r2)

  belongs_to :author,  class_name: User
  belongs_to :person,  class_name: Dorsale::CustomerVault::Person

  validates :person,       presence: true
  validates :date,         presence: true
  validates :text,         presence: true
  validates :action,       presence: true, inclusion: {in: proc { ACTIONS }}
  validates :contact_type, presence: true, inclusion: {in: proc { CONTACT_TYPES }}

  default_scope -> {
    all
      .order(created_at: :desc, id: :desc)
      .preload(:author, :person)
  }

  private

  def assign_default_values
    assign_default :date, Date.current
    assign_default :contact_type, CONTACT_TYPES.first
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dorsale-3.10.3 app/models/dorsale/customer_vault/event.rb
dorsale-3.10.2 app/models/dorsale/customer_vault/event.rb
dorsale-3.10.1 app/models/dorsale/customer_vault/event.rb
dorsale-3.10.0 app/models/dorsale/customer_vault/event.rb
dorsale-3.9.8 app/models/dorsale/customer_vault/event.rb
dorsale-3.9.7 app/models/dorsale/customer_vault/event.rb
dorsale-3.9.6 app/models/dorsale/customer_vault/event.rb
dorsale-3.9.5 app/models/dorsale/customer_vault/event.rb
dorsale-3.9.4 app/models/dorsale/customer_vault/event.rb
dorsale-3.9.3 app/models/dorsale/customer_vault/event.rb
dorsale-3.9.2 app/models/dorsale/customer_vault/event.rb
dorsale-3.9.1 app/models/dorsale/customer_vault/event.rb
dorsale-3.9.0 app/models/dorsale/customer_vault/event.rb