Class: ShopProductVariant
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ShopProductVariant
- Defined in:
- app/models/shop_product_variant.rb
Instance Method Summary collapse
- #name ⇒ Object
-
#price ⇒ Object
Returns the price of the variant plus the product price.
-
#sku ⇒ Object
Returns a mixed sku of product and variant name.
-
#slug ⇒ Object
Returns slug of the product.
- #to_param ⇒ Object
- #url ⇒ Object
Instance Method Details
#name ⇒ Object
19 20 21 |
# File 'app/models/shop_product_variant.rb', line 19 def name %{#{product.name} #{self[:name]}} end |
#price ⇒ Object
Returns the price of the variant plus the product price
24 25 26 27 28 29 30 |
# File 'app/models/shop_product_variant.rb', line 24 def price price = product.price if read_attribute(:price).present? price = read_attribute(:price) + product.price end price end |
#sku ⇒ Object
Returns a mixed sku of product and variant name
33 34 35 36 37 38 39 |
# File 'app/models/shop_product_variant.rb', line 33 def sku sku = nil if self[:name].present? sku = %{#{product.sku}-#{self[:name].gsub(/[^a-zA-Z0-9_]/,"_")}} end sku end |
#slug ⇒ Object
Returns slug of the product
42 43 44 |
# File 'app/models/shop_product_variant.rb', line 42 def slug product.slug end |
#to_param ⇒ Object
50 51 52 |
# File 'app/models/shop_product_variant.rb', line 50 def to_param product.to_param end |
#url ⇒ Object
46 47 48 |
# File 'app/models/shop_product_variant.rb', line 46 def url product.url end |