Sha256: 14329c6a2b2cc0194944cbff65e2572f4b87cf571da87a1ad0dabd4a64f03713

Contents?: true

Size: 776 Bytes

Versions: 38

Compression:

Stored size: 776 Bytes

Contents

module Comee
  module Core
    class CustomerOrder < ApplicationRecord
      belongs_to :client
      has_many :customer_order_items
      has_one_attached :file

      enum :status, {draft: 0, submitted: 1, awaiting_confirmation: 2, accepted: 3, canceled: 4}

      validates :order_number, :order_date, :delivery_address, :invoice_address, :status, presence: true

      def self.ransackable_attributes(_auth_object = nil)
        %w[client_id delivery_address invoice_address order_number status]
      end

      def self.ransackable_associations(_auth_object = nil)
        %w[client customer_order_items]
      end

      def file_url
        file.attached? ? Rails.application.routes.url_helpers.rails_blob_url(file, only_path: false) : nil
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
comee_core-0.1.90 app/models/comee/core/customer_order.rb
comee_core-0.1.89 app/models/comee/core/customer_order.rb
comee_core-0.1.88 app/models/comee/core/customer_order.rb
comee_core-0.1.87 app/models/comee/core/customer_order.rb
comee_core-0.1.86 app/models/comee/core/customer_order.rb
comee_core-0.1.85 app/models/comee/core/customer_order.rb
comee_core-0.1.84 app/models/comee/core/customer_order.rb
comee_core-0.1.83 app/models/comee/core/customer_order.rb
comee_core-0.1.82 app/models/comee/core/customer_order.rb
comee_core-0.1.81 app/models/comee/core/customer_order.rb
comee_core-0.1.80 app/models/comee/core/customer_order.rb
comee_core-0.1.79 app/models/comee/core/customer_order.rb
comee_core-0.1.78 app/models/comee/core/customer_order.rb
comee_core-0.1.77 app/models/comee/core/customer_order.rb
comee_core-0.1.76 app/models/comee/core/customer_order.rb
comee_core-0.1.75 app/models/comee/core/customer_order.rb
comee_core-0.1.74 app/models/comee/core/customer_order.rb
comee_core-0.1.73 app/models/comee/core/customer_order.rb
comee_core-0.1.72 app/models/comee/core/customer_order.rb
comee_core-0.1.71 app/models/comee/core/customer_order.rb