1 class BonusPurchase < Purchase
5 validates_presence_of :rentable_id
6 validates_numericality_of :rentable_id
8 def self.last_bonus_date(customer,bonus_type,since_date)
9 bonuses = BonusPurchase.find_all_by_customer_id(customer, :conditions => ["date >= ?", since_date], :order => 'date DESC')
11 if bonus.rentable.class.to_s == bonus_type.to_s
16 # Unable to find a last bonus, no bonuses in period
22 errors.add(:rentable_id, "is not in the database") if rentable.nil?