Add Income tracking to the Purchase System
[cs356-p2-videostore.git] / app / models / purchase.rb
index ff07e41..b596aa2 100644 (file)
@@ -6,6 +6,16 @@ class Purchase < ActiveRecord::Base
   validates_presence_of :price
   validates_numericality_of :price
 
+  def title
+    if type == MerchandisePurchase
+      return merchandise.title
+    elsif type == RentablePurchase
+      return rentable.title
+    else
+      return 'Late Fees'
+    end
+  end
+
   protected
   def validate
     errors.add(:price, "cannot be negative") if price < 0