projects
/
depot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
End chapter 10
[depot.git]
/
app
/
models
/
line_item.rb
diff --git
a/app/models/line_item.rb
b/app/models/line_item.rb
index 988324ce31782a3ecf6e441960390f484968b478..61161a02a87601a5cf550bf08fd26cb071d80c20 100644
(file)
--- a/
app/models/line_item.rb
+++ b/
app/models/line_item.rb
@@
-1,2
+1,12
@@
class LineItem < ActiveRecord::Base
class LineItem < ActiveRecord::Base
+ belongs_to :order
+ belongs_to :product
+
+ def self.from_cart_item(cart_item)
+ li = self.new
+ li.product = cart_item.product
+ li.quantity = cart_item.quantity
+ li.total_price = cart_item.price
+ li
+ end
end
end