Class: Dscf::Marketplace::Product
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Dscf::Marketplace::Product
- Defined in:
- app/models/dscf/marketplace/product.rb
Class Method Summary collapse
- .ransackable_associations(_auth_object = nil) ⇒ Object
-
.ransackable_attributes(_auth_object = nil) ⇒ Object
Ransack configuration for secure filtering.
Instance Method Summary collapse
- #category_path ⇒ Object
- #convertible_to_units ⇒ Object
- #display_name ⇒ Object
- #images_urls ⇒ Object
- #price_per_unit ⇒ Object
- #thumbnail_url ⇒ Object
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
35 36 37 |
# File 'app/models/dscf/marketplace/product.rb', line 35 def self.ransackable_associations(_auth_object = nil) %w[category unit supplier_products listings order_items rfq_items quotation_items] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
Ransack configuration for secure filtering
31 32 33 |
# File 'app/models/dscf/marketplace/product.rb', line 31 def self.ransackable_attributes(_auth_object = nil) %w[id sku name description category_id unit_id base_price base_quantity business_only created_at updated_at] end |
Instance Method Details
#category_path ⇒ Object
48 49 50 51 |
# File 'app/models/dscf/marketplace/product.rb', line 48 def category_path return nil unless category category.ancestry_path end |
#convertible_to_units ⇒ Object
53 54 55 56 |
# File 'app/models/dscf/marketplace/product.rb', line 53 def convertible_to_units return [] unless unit unit.convertible_units end |
#display_name ⇒ Object
39 40 41 |
# File 'app/models/dscf/marketplace/product.rb', line 39 def display_name "#{name} (#{sku})" end |
#images_urls ⇒ Object
62 63 64 65 |
# File 'app/models/dscf/marketplace/product.rb', line 62 def images_urls return [] unless images.attached? images.map { |image| (image) } end |
#price_per_unit ⇒ Object
43 44 45 46 |
# File 'app/models/dscf/marketplace/product.rb', line 43 def price_per_unit return nil unless base_price && base_quantity && base_quantity > 0 base_price / base_quantity end |
#thumbnail_url ⇒ Object
58 59 60 |
# File 'app/models/dscf/marketplace/product.rb', line 58 def thumbnail_url (thumbnail) end |