projects
/
cs356-p2-videostore.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Small Cleanups + Merchandise Search
[cs356-p2-videostore.git]
/
app
/
models
/
purchase.rb
diff --git
a/app/models/purchase.rb
b/app/models/purchase.rb
index
ff07e41
..
0f01813
100644
(file)
--- a/
app/models/purchase.rb
+++ b/
app/models/purchase.rb
@@
-6,10
+6,23
@@
class Purchase < ActiveRecord::Base
validates_presence_of :price
validates_numericality_of :price
validates_presence_of :price
validates_numericality_of :price
+ def title
+ if self.class == MerchandisePurchase
+ return merchandise.title
+ elsif self.class == RentablePurchase
+ return rentable.title
+ elsif self.class == BonusPurchase
+ return rentable.title
+ else
+ return 'Late Fees'
+ end
+ end
+
protected
def validate
errors.add(:price, "cannot be negative") if price < 0
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
errors.add(:customer_id, "does not exist in the database") if customer.nil?
end
end