projects
/
depot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Finished Chapter 12
[depot.git]
/
app
/
models
/
product.rb
diff --git
a/app/models/product.rb
b/app/models/product.rb
index 27fbdabe21bba36592467e18883ed7556e0f039f..4854ee5c213d4f31da3bae6e6a31466582157667 100644
(file)
--- a/
app/models/product.rb
+++ b/
app/models/product.rb
@@
-1,4
+1,7
@@
class Product < ActiveRecord::Base
+ has_many :line_items
+ has_many :orders, :through => :line_items
+
validates_presence_of :title, :description, :image_url
validates_numericality_of :price
validate :price_must_be_at_least_a_penny