Sha256: 40a2c11e3b419528c0a6f97c534251aea69b9198eacc6d3c08577e4cf892f9a4

Contents?: true

Size: 901 Bytes

Versions: 35

Compression:

Stored size: 901 Bytes

Contents

module Comee
  module Core
    class Client < ApplicationRecord
      belongs_to :user, optional: true
      belongs_to :parent, class_name: "Comee::Core::Client", optional: true
      belongs_to :currency, optional: true
      has_and_belongs_to_many :contacts, join_table: :comee_core_clients_contacts
      has_and_belongs_to_many :agents, join_table: :comee_core_clients_agents
      has_many :client_warehouses

      validates :code, :name, :address, :locale, presence: true
      validates :code, uniqueness: true

      delegate(:name, to: :user, prefix: true, allow_nil: true)

      def self.ransackable_attributes(_auth_object = nil)
        %w[
          id
          user_id
          address
          code
          name
          locale
          parent_id
        ]
      end

      def self.ransackable_associations(_auth_object = nil)
        ["parent"]
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
comee_core-0.2.31 app/models/comee/core/client.rb
comee_core-0.2.30 app/models/comee/core/client.rb
comee_core-0.2.29 app/models/comee/core/client.rb
comee_core-0.2.28 app/models/comee/core/client.rb
comee_core-0.2.27 app/models/comee/core/client.rb
comee_core-0.2.26 app/models/comee/core/client.rb
comee_core-0.2.25 app/models/comee/core/client.rb
comee_core-0.2.24 app/models/comee/core/client.rb
comee_core-0.2.23 app/models/comee/core/client.rb
comee_core-0.2.22 app/models/comee/core/client.rb
comee_core-0.2.21 app/models/comee/core/client.rb
comee_core-0.2.20 app/models/comee/core/client.rb
comee_core-0.2.19 app/models/comee/core/client.rb
comee_core-0.2.18 app/models/comee/core/client.rb
comee_core-0.2.17 app/models/comee/core/client.rb
comee_core-0.2.16 app/models/comee/core/client.rb
comee_core-0.2.15 app/models/comee/core/client.rb
comee_core-0.2.14 app/models/comee/core/client.rb
comee_core-0.2.13 app/models/comee/core/client.rb
comee_core-0.2.12 app/models/comee/core/client.rb