X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=app%2Fmodels%2Fpurchase.rb;h=0f018131b54b6315dec82eb9f20ce5992c856fcc;hb=da871e3e27c31759e0d017c89ccf16a14db1a227;hp=b596aa285d550265001d96252e75d8725248c648;hpb=8aced6893e5ea362fe6f7460b9341a2dbe745025;p=cs356-p2-videostore.git diff --git a/app/models/purchase.rb b/app/models/purchase.rb index b596aa2..0f01813 100644 --- a/app/models/purchase.rb +++ b/app/models/purchase.rb @@ -7,9 +7,11 @@ class Purchase < ActiveRecord::Base 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' @@ -19,7 +21,8 @@ class Purchase < ActiveRecord::Base 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