Class: Product
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Product
- Extended by:
- FriendlyId
- Defined in:
- app/models/product.rb
Instance Method Summary collapse
- #current_price ⇒ Object
- #promotional_discount ⇒ Object
- #promotional_price? ⇒ Boolean
- #slug_candidates ⇒ Object
Instance Method Details
#current_price ⇒ Object
22 23 24 |
# File 'app/models/product.rb', line 22 def current_price promotional_price? ? promotional_price : price end |
#promotional_discount ⇒ Object
30 31 32 |
# File 'app/models/product.rb', line 30 def promotional_discount promotional_price? ? (1 - promotional_price / price) * 100 : 0 end |
#promotional_price? ⇒ Boolean
26 27 28 |
# File 'app/models/product.rb', line 26 def promotional_price? promotional_price.present? && promotional_price.to_i > 0 end |
#slug_candidates ⇒ Object
18 19 20 |
# File 'app/models/product.rb', line 18 def slug_candidates [[:name, :sku]] end |