Class: ShipmentContent

Inherits:
ApplicationRecord show all
Defined in:
app/models/shipment_content.rb

Overview

== Schema Information

Table name: shipment_contents
Database name: primary

id :integer not null, primary key
quantity :integer
line_item_id :integer not null
shipment_id :integer not null

Indexes

idx_line_item_shipment (line_item_id,shipment_id)
index_shipment_contents_on_shipment_id (shipment_id)

Foreign Keys

fk_rails_... (line_item_id => line_items.id) ON DELETE => cascade
fk_rails_... (shipment_id => shipments.id) ON DELETE => cascade

Constant Summary

Constants included from Schedulable

Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Belongs to collapse

Class Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#quantityObject (readonly)



26
# File 'app/models/shipment_content.rb', line 26

validates :quantity, numericality: { only_integer: true, greater_than_or_equal_to: 1 }

Class Method Details

.from_completed_shipmentsActiveRecord::Relation<ShipmentContent>

A relation of ShipmentContents that are from completed shipments. Active Record Scope

Returns:

See Also:



29
# File 'app/models/shipment_content.rb', line 29

scope :from_completed_shipments, -> { joins(:shipment).merge(Shipment.completed) }

Instance Method Details

#line_itemLineItem

Returns:

See Also:



24
# File 'app/models/shipment_content.rb', line 24

belongs_to :line_item, optional: true

#shipmentShipment

Returns:

See Also:



23
# File 'app/models/shipment_content.rb', line 23

belongs_to :shipment, optional: true