validates_numericality_of :price
def title
- if type == MerchandisePurchase
+ if self.class == MerchandisePurchase
return merchandise.title
- elsif type == RentablePurchase
+ elsif self.class == RentablePurchase
+ return rentable.title
+ elsif self.class == BonusPurchase
return rentable.title
else
return 'Late Fees'
protected
def validate
errors.add(:price, "cannot be negative") if price < 0
- errors.add(:price, "cannot be less than $0.01") if price < 0.01
+ # Need to leave this out for bonuses
+ #errors.add(:price, "cannot be less than $0.01") if price < 0.01
errors.add(:customer_id, "does not exist in the database") if customer.nil?
end
end