Class: Sale

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/sale.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) for(product_id, at)



12
13
14
# File 'app/models/sale.rb', line 12

def self.for(product_id, at)
  where(['sales.product_id = ? AND sales.starts_at <= ? AND sales.ends_at > ?', product_id, at, at]).order('sales.percent_off DESC').first
end