Class: AssortmentInstruction
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- AssortmentInstruction
- Includes:
- Models::Auditable
- Defined in:
- app/models/assortment_instruction.rb
Overview
== Schema Information
Table name: assortment_instructions
Database name: primary
id :integer not null, primary key
active :boolean default(TRUE)
final_rule :boolean default(TRUE)
instruction_type :enum not null
position :integer
title :string
created_at :datetime not null
updated_at :datetime not null
creator_id :integer
customer_filter_id :integer
email_template_id :integer
updater_id :integer
Indexes
index_assortment_instructions_on_customer_filter_id (customer_filter_id)
index_assortment_instructions_on_instruction_type (instruction_type)
Foreign Keys
fk_rails_... (customer_filter_id => customer_filters.id)
fk_rails_... (email_template_id => email_templates.id)
Constant Summary
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Constants included from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
- #customer_filter_id ⇒ Object readonly
- #email_template_id ⇒ Object readonly
- #title ⇒ Object readonly
Belongs to collapse
Methods included from Models::Auditable
Has many collapse
Has and belongs to many collapse
-
#items ⇒ ActiveRecord::Relation<Item>
for publications.
Class Method Summary collapse
-
.active ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are active.
-
.for_customer ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are for customer.
- .instruction_types_for_select ⇒ Object
-
.sorted ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are sorted.
Instance Method Summary collapse
- #line_items_qualify?(line_items) ⇒ Boolean
-
#to_partial_path ⇒ Object
Partial lives under
app/views/crm/assortment_instructions/, not the conventionalapp/views/assortment_instructions/.
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#customer_filter_id ⇒ Object (readonly)
51 |
# File 'app/models/assortment_instruction.rb', line 51 validates :customer_filter_id, :email_template_id, :title, presence: true |
#email_template_id ⇒ Object (readonly)
51 |
# File 'app/models/assortment_instruction.rb', line 51 validates :customer_filter_id, :email_template_id, :title, presence: true |
#title ⇒ Object (readonly)
51 |
# File 'app/models/assortment_instruction.rb', line 51 validates :customer_filter_id, :email_template_id, :title, presence: true |
Class Method Details
.active ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are active. Active Record Scope
58 |
# File 'app/models/assortment_instruction.rb', line 58 scope :active, -> { where(active: true) } |
.for_customer ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are for customer. Active Record Scope
59 |
# File 'app/models/assortment_instruction.rb', line 59 scope :for_customer, ->(customer) { where(customer_filter_id: CustomerFilter::QueryBuilder.filter_ids_for_customer(customer)).order(:position) } |
.instruction_types_for_select ⇒ Object
64 65 66 |
# File 'app/models/assortment_instruction.rb', line 64 def self.instruction_types_for_select instruction_types.invert.keys.map { |k| [k.to_s.humanize.titleize, k] } end |
.sorted ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are sorted. Active Record Scope
60 |
# File 'app/models/assortment_instruction.rb', line 60 scope :sorted, -> { order(:position) } |
Instance Method Details
#customer_filter ⇒ CustomerFilter
41 |
# File 'app/models/assortment_instruction.rb', line 41 belongs_to :customer_filter, optional: true |
#email_template ⇒ EmailTemplate
42 |
# File 'app/models/assortment_instruction.rb', line 42 belongs_to :email_template, optional: true |
#items ⇒ ActiveRecord::Relation<Item>
for publications
44 |
# File 'app/models/assortment_instruction.rb', line 44 has_and_belongs_to_many :items, inverse_of: :assortment_instructions |
#line_items_qualify?(line_items) ⇒ Boolean
68 69 70 |
# File 'app/models/assortment_instruction.rb', line 68 def line_items_qualify?(line_items) ProductFilter::LineQualifier.new(line_items, product_filters). end |
#product_filters ⇒ ActiveRecord::Relation<ProductFilter>
Validations:
43 |
# File 'app/models/assortment_instruction.rb', line 43 has_many :product_filters, dependent: :destroy, inverse_of: :assortment_instruction |
#to_partial_path ⇒ Object
Partial lives under app/views/crm/assortment_instructions/, not the
conventional app/views/assortment_instructions/. Override so
render @assortment_instructions resolves correctly from any
controller, not just Crm::AssortmentInstructionsController.
37 38 39 |
# File 'app/models/assortment_instruction.rb', line 37 def to_partial_path 'crm/assortment_instructions/assortment_instruction' end |