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)
Instance Attribute Summary collapse
- #name ⇒ Object readonly
Belongs to collapse
-
#supplier ⇒ Supplier
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) ⇒ Object
-
.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::EventPublishable
Instance Attribute Details
#name ⇒ Object (readonly)
36 |
# File 'app/models/carrier.rb', line 36 validates :name, presence: true |
Class Method Details
.for_country ⇒ ActiveRecord::Relation<Carrier>
A relation of Carriers that are for country. Active Record Scope
39 |
# File 'app/models/carrier.rb', line 39 scope :for_country, ->(country_iso) { where.any(country_iso: country_iso) } |
.lookup ⇒ ActiveRecord::Relation<Carrier>
A relation of Carriers that are lookup. Active Record Scope
40 |
# File 'app/models/carrier.rb', line 40 scope :lookup, -> (q) { where(Carrier[:scac].matches("%#{q}%").or( Carrier[:name].matches("%#{q}%") ).or( Carrier[:full_name].matches("%#{q}%") ) )} |
.ransackable_scopes(_auth_object = nil) ⇒ Object
42 43 44 |
# File 'app/models/carrier.rb', line 42 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
38 |
# File 'app/models/carrier.rb', line 38 scope :with_scac_code, -> { where.not(scac: nil) } |
Instance Method Details
#supplier ⇒ Supplier
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
31 |
# File 'app/models/carrier.rb', line 31 belongs_to :supplier, optional: true |