Sha256: c2589d097fe29ed17a639ae3901b1c73deea9b79ecb22d3151e0fec387d8bd26

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 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, allow_blank: 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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dorsale-3.8.0 app/models/dorsale/customer_vault/event.rb