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))
Instance Attribute Summary collapse
- #node_id ⇒ Object readonly
- #node_path ⇒ Object readonly
Has and belongs to many collapse
- #amazon_variations ⇒ ActiveRecord::Relation<AmazonVariation>
- #catalog_items ⇒ ActiveRecord::Relation<CatalogItem>
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::EventPublishable
Instance Attribute Details
#node_id ⇒ Object (readonly)
26 |
# File 'app/models/amazon_browse_node.rb', line 26 validates :node_id, presence: true |
#node_path ⇒ Object (readonly)
27 |
# File 'app/models/amazon_browse_node.rb', line 27 validates :node_path, presence: true |
Class Method Details
.search_node ⇒ ActiveRecord::Relation<AmazonBrowseNode>
A relation of AmazonBrowseNodes that are search node. Active Record Scope
29 30 31 32 33 34 |
# File 'app/models/amazon_browse_node.rb', line 29 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
25 |
# File 'app/models/amazon_browse_node.rb', line 25 belongs_to :amazon_marketplace |
#amazon_variations ⇒ ActiveRecord::Relation<AmazonVariation>
23 |
# File 'app/models/amazon_browse_node.rb', line 23 has_and_belongs_to_many :amazon_variations |
#catalog_items ⇒ ActiveRecord::Relation<CatalogItem>
22 |
# File 'app/models/amazon_browse_node.rb', line 22 has_and_belongs_to_many :catalog_items |
#to_s ⇒ Object
36 37 38 |
# File 'app/models/amazon_browse_node.rb', line 36 def to_s %(#{node_id} - #{node_path}#{(+' (' + item_type_keyword + ')') if item_type_keyword} [#{amazon_marketplace.country.iso}]) end |