Class: Dscf::Marketplace::Product
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Dscf::Marketplace::Product
- Includes:
- AttachmentUrls
- 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
38 39 40 |
# File 'app/models/dscf/marketplace/product.rb', line 38 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
34 35 36 |
# File 'app/models/dscf/marketplace/product.rb', line 34 def self.ransackable_attributes(_auth_object = nil) %w[id sku name description category_id unit_id gross_weight base_quantity business_only created_at updated_at] end |
Instance Method Details
#category_path ⇒ Object
51 52 53 54 |
# File 'app/models/dscf/marketplace/product.rb', line 51 def category_path return nil unless category category.ancestry_path end |
#convertible_to_units ⇒ Object
56 57 58 59 |
# File 'app/models/dscf/marketplace/product.rb', line 56 def convertible_to_units return [] unless unit unit.convertible_units end |
#display_name ⇒ Object
42 43 44 |
# File 'app/models/dscf/marketplace/product.rb', line 42 def display_name "#{name} (#{sku})" end |
#images_urls ⇒ Object
65 66 67 68 |
# File 'app/models/dscf/marketplace/product.rb', line 65 def images_urls return [] unless images.attached? images.map { |image| (image) } end |
#price_per_unit ⇒ Object
46 47 48 49 |
# File 'app/models/dscf/marketplace/product.rb', line 46 def price_per_unit return nil unless base_quantity && base_quantity > 0 nil end |
#thumbnail_url ⇒ Object
61 62 63 |
# File 'app/models/dscf/marketplace/product.rb', line 61 def thumbnail_url (thumbnail) end |