Class: Carrier
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Carrier
- Defined in:
- app/models/carrier.rb
Overview
== Schema Information
Table name: carriers
Database name: primary
id :bigint not null, primary key
common :boolean default(FALSE), not null
countries_iso :string default([]), is an Array
full_name :string
name :string
scac :string
created_at :datetime not null
updated_at :datetime not null
supplier_id :integer
Indexes
index_carriers_on_countries_iso (countries_iso) USING gin
index_carriers_on_full_name (full_name) USING gin
index_carriers_on_name (name) USING gin
index_carriers_on_scac (scac) UNIQUE
index_carriers_on_supplier_id (supplier_id)
Foreign Keys
fk_rails_... (supplier_id => parties.id)
Constant Summary
Constants included from Models::Schedulable
Models::Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
-
#name ⇒ String?
Carrier display name.
Belongs to collapse
-
#supplier ⇒ Party
scac code being a US specific code we don't want to enforce it if we deal with european or other carriers that do not have one.
Class Method Summary collapse
-
.for_country ⇒ ActiveRecord::Relation<Carrier>
A relation of Carriers that are for country.
-
.lookup ⇒ ActiveRecord::Relation<Carrier>
A relation of Carriers that are lookup.
-
.ransackable_scopes(_auth_object = nil) ⇒ Array<Symbol>
Ransack scopes exposed to search.
-
.with_scac_code ⇒ ActiveRecord::Relation<Carrier>
A relation of Carriers that are with scac code.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransortable_attributes, #to_relation
Methods included from Models::Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#name ⇒ String?
Returns Carrier display name.
40 |
# File 'app/models/carrier.rb', line 40 validates :name, presence: true |
Class Method Details
.for_country ⇒ ActiveRecord::Relation<Carrier>
A relation of Carriers that are for country. Active Record Scope
43 |
# File 'app/models/carrier.rb', line 43 scope :for_country, ->(country_iso) { where.overlap(countries_iso: country_iso) } |
.lookup ⇒ ActiveRecord::Relation<Carrier>
A relation of Carriers that are lookup. Active Record Scope
44 |
# File 'app/models/carrier.rb', line 44 scope :lookup, ->(q) { where(Carrier[:scac].matches("%#{q}%").or(Carrier[:name].matches("%#{q}%")).or(Carrier[:full_name].matches("%#{q}%"))) } |
.ransackable_scopes(_auth_object = nil) ⇒ Array<Symbol>
Ransack scopes exposed to search.
50 51 52 |
# File 'app/models/carrier.rb', line 50 def self.ransackable_scopes(_auth_object = nil) %i[lookup for_country] end |
.with_scac_code ⇒ ActiveRecord::Relation<Carrier>
A relation of Carriers that are with scac code. Active Record Scope
42 |
# File 'app/models/carrier.rb', line 42 scope :with_scac_code, -> { where.not(scac: nil) } |
Instance Method Details
#supplier ⇒ Party
scac code being a US specific code we don't want to enforce it if we deal
with european or other carriers that do not have one
33 |
# File 'app/models/carrier.rb', line 33 belongs_to :supplier, optional: true |