Class: Product

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/product.rb

Instance Method Summary collapse

Instance Method Details

#current_priceObject



22
23
24
# File 'app/models/product.rb', line 22

def current_price
  promotional_price? ? promotional_price : price
end

#promotional_discountObject



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

Returns:

  • (Boolean)


26
27
28
# File 'app/models/product.rb', line 26

def promotional_price?
  promotional_price.present? && promotional_price.to_i > 0
end

#slug_candidatesObject



18
19
20
# File 'app/models/product.rb', line 18

def slug_candidates
  [[:name, :sku]]
end