Sha256: 0a91d1491857eb64989074cb7c2432fe29782777b917f93e71e11920d5db8d20

Contents?: true

Size: 779 Bytes

Versions: 104

Compression:

Stored size: 779 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[id 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

104 entries across 104 versions & 1 rubygems

Version Path
comee_core-0.2.99 app/models/comee/core/customer_order.rb
comee_core-0.2.98 app/models/comee/core/customer_order.rb
comee_core-0.2.97 app/models/comee/core/customer_order.rb
comee_core-0.2.96 app/models/comee/core/customer_order.rb
comee_core-0.2.95 app/models/comee/core/customer_order.rb
comee_core-0.2.94 app/models/comee/core/customer_order.rb
comee_core-0.2.93 app/models/comee/core/customer_order.rb
comee_core-0.2.92 app/models/comee/core/customer_order.rb
comee_core-0.2.91 app/models/comee/core/customer_order.rb
comee_core-0.2.90 app/models/comee/core/customer_order.rb
comee_core-0.2.89 app/models/comee/core/customer_order.rb
comee_core-0.2.88 app/models/comee/core/customer_order.rb
comee_core-0.2.87 app/models/comee/core/customer_order.rb
comee_core-0.2.86 app/models/comee/core/customer_order.rb
comee_core-0.2.85 app/models/comee/core/customer_order.rb
comee_core-0.2.84 app/models/comee/core/customer_order.rb
comee_core-0.2.83 app/models/comee/core/customer_order.rb
comee_core-0.2.82 app/models/comee/core/customer_order.rb
comee_core-0.2.81 app/models/comee/core/customer_order.rb
comee_core-0.2.80 app/models/comee/core/customer_order.rb