Sha256: 97be472041d47bc8e2af9ea8770237fb238b1e01d5c15e886c27523d7c1aad05
Contents?: true
Size: 893 Bytes
Versions: 1
Compression:
Stored size: 893 Bytes
Contents
module Comee module Core class ClientAddress < Address belongs_to :client validates :name, presence: true validate :validate_default def validate_default return unless client && address_type && default default_count = if new_record? ClientAddress.where(address_type: address_type, client: client, default: true).count else ClientAddress.where(address_type: address_type, client: client, default: true) .where.not(id: id).count end return if default_count.zero? errors.add(:default, "cannot be set to true. There is already a default address for this client and address type.") end def ransackable_attributes(_auth_object = nil) %w[name] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comee_core-0.3.57 | app/models/comee/core/client_address.rb |