Sha256: 4aab06e5703a7f123a8dd19e5099faabaf8e4416ab150fcf59d65279120cd4a9

Contents?: true

Size: 850 Bytes

Versions: 23

Compression:

Stored size: 850 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

23 entries across 23 versions & 1 rubygems

Version Path
dorsale-4.0.0 app/models/dorsale/customer_vault/event.rb
dorsale-3.20.0 app/models/dorsale/customer_vault/event.rb
dorsale-3.19.1 app/models/dorsale/customer_vault/event.rb
dorsale-3.19.0 app/models/dorsale/customer_vault/event.rb
dorsale-3.18.0 app/models/dorsale/customer_vault/event.rb
dorsale-3.17.0 app/models/dorsale/customer_vault/event.rb
dorsale-3.16.0 app/models/dorsale/customer_vault/event.rb
dorsale-3.15.0 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.11 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.10 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.9 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.8 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.7 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.6 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.5 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.4 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.3 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.2 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.1 app/models/dorsale/customer_vault/event.rb
dorsale-3.14.0 app/models/dorsale/customer_vault/event.rb