Class: Comable::Product
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Comable::Product
- Includes:
- Liquidable, Csvable, Search, Ransackable, SkuItem
- Defined in:
- app/models/comable/product.rb,
app/models/comable/product/csvable.rb,
app/models/concerns/comable/product/search.rb
Defined Under Namespace
Constant Summary
Constants included from Search
Instance Method Summary collapse
- #category_path_names=(category_path_names, delimiter: Comable::Category::DEFAULT_PATH_NAME_DELIMITER) ⇒ Object
- #image_url ⇒ Object
-
#images ⇒ Object
Add conditions for the images association.
- #stocked? ⇒ Boolean
- #unstocked? ⇒ Boolean
Methods included from SkuItem
Instance Method Details
#category_path_names=(category_path_names, delimiter: Comable::Category::DEFAULT_PATH_NAME_DELIMITER) ⇒ Object
45 46 47 |
# File 'app/models/comable/product.rb', line 45 def category_path_names=(category_path_names, delimiter: Comable::Category::DEFAULT_PATH_NAME_DELIMITER) self.categories = Comable::Category.find_by_path_names(category_path_names, delimiter: delimiter) end |
#image_url ⇒ Object
31 32 33 34 35 |
# File 'app/models/comable/product.rb', line 31 def image_url image = images.first return image.url if image 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTcxIiBoZWlnaHQ9IjE4MCIgdmlld0JveD0iMCAwIDE3MSAxODAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxkZWZzLz48cmVjdCB3aWR0aD0iMTcxIiBoZWlnaHQ9IjE4MCIgZmlsbD0iI0VFRUVFRSIvPjxnPjx0ZXh0IHg9IjU4IiB5PSI5MCIgc3R5bGU9ImZpbGw6I0FBQUFBQTtmb250LXdlaWdodDpib2xkO2ZvbnQtZmFtaWx5OkFyaWFsLCBIZWx2ZXRpY2EsIE9wZW4gU2Fucywgc2Fucy1zZXJpZiwgbW9ub3NwYWNlO2ZvbnQtc2l6ZToxMHB0O2RvbWluYW50LWJhc2VsaW5lOmNlbnRyYWwiPjE3MXgxODA8L3RleHQ+PC9nPjwvc3ZnPg==' end |
#images ⇒ Object
Add conditions for the images association. Override method of the images association to support Rails 3.x.
27 28 29 |
# File 'app/models/comable/product.rb', line 27 def images super.order(:id) end |
#stocked? ⇒ Boolean
37 38 39 |
# File 'app/models/comable/product.rb', line 37 def stocked? stocks.stocked.exists? end |
#unstocked? ⇒ Boolean
41 42 43 |
# File 'app/models/comable/product.rb', line 41 def unstocked? !stocked? end |