Class: AmazonBrowseNode
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- AmazonBrowseNode
- Defined in:
- app/models/amazon_browse_node.rb
Overview
== Schema Information
Table name: amazon_browse_nodes
Database name: primary
id :bigint not null, primary key
item_type_keyword :string
node_path :text not null
created_at :datetime not null
updated_at :datetime not null
amazon_marketplace_id :integer not null
node_id :string not null
Indexes
index_amazon_browse_nodes_on_item_type_keyword (item_type_keyword) USING gin
index_amazon_browse_nodes_on_node_id (node_id)
index_amazon_browse_nodes_on_node_path (node_path) USING gin
unique_amazon_browse_nodes (amazon_marketplace_id, node_id, COALESCE(item_type_keyword, ''::character varying))
Constant Summary
Constants included from Models::Schedulable
Models::Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
-
#node_id ⇒ String
Amazon browse node id.
-
#node_path ⇒ String
Human-readable browse node path.
Has and belongs to many collapse
- #catalog_items ⇒ ActiveRecord::Relation<CatalogItem>
- #variant_groups ⇒ ActiveRecord::Relation<VariantGroup>
Belongs to collapse
Class Method Summary collapse
-
.search_node ⇒ ActiveRecord::Relation<AmazonBrowseNode>
A relation of AmazonBrowseNodes that are search node.
Instance Method Summary collapse
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#node_id ⇒ String
Returns Amazon browse node id.
37 |
# File 'app/models/amazon_browse_node.rb', line 37 validates :node_id, presence: true |
#node_path ⇒ String
Returns Human-readable browse node path.
Validations:
37 |
# File 'app/models/amazon_browse_node.rb', line 37 validates :node_id, presence: true |
Class Method Details
.search_node ⇒ ActiveRecord::Relation<AmazonBrowseNode>
A relation of AmazonBrowseNodes that are search node. Active Record Scope
40 41 42 43 44 45 |
# File 'app/models/amazon_browse_node.rb', line 40 scope :search_node, ->(q) { q_wild = "'%#{q}%'".sql_safe where(AmazonBrowseNode[:node_id].eq(q) .or(AmazonBrowseNode[:node_path].matches(q_wild)) .or(AmazonBrowseNode[:item_type_keyword].matches(q_wild))) } |
Instance Method Details
#amazon_marketplace ⇒ AmazonMarketplace
31 |
# File 'app/models/amazon_browse_node.rb', line 31 belongs_to :amazon_marketplace |
#catalog_items ⇒ ActiveRecord::Relation<CatalogItem>
25 |
# File 'app/models/amazon_browse_node.rb', line 25 has_and_belongs_to_many :catalog_items |
#to_s ⇒ String
48 49 50 |
# File 'app/models/amazon_browse_node.rb', line 48 def to_s %(#{node_id} - #{node_path}#{"#{+' ('}#{item_type_keyword})" if item_type_keyword} [#{amazon_marketplace.country.iso}]) end |
#variant_groups ⇒ ActiveRecord::Relation<VariantGroup>
27 28 |
# File 'app/models/amazon_browse_node.rb', line 27 has_and_belongs_to_many :variant_groups, join_table: 'amazon_browse_nodes_variant_groups' |