projects
/
depot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Finished chapter 11
[depot.git]
/
app
/
models
/
cart.rb
diff --git
a/app/models/cart.rb
b/app/models/cart.rb
index 0f1d52e731588dd79ac0bde3fe487761d93ad3be..bd51c383311d6a0a008208a3908955e330be963a 100644
(file)
--- a/
app/models/cart.rb
+++ b/
app/models/cart.rb
@@
-10,12
+10,18
@@
class Cart
if current_item
current_item.increment_quantity
else
if current_item
current_item.increment_quantity
else
- @items << CartItem.new(product)
+ current_item = CartItem.new(product)
+ @items << current_item
end
end
+ current_item
end
def total_price
@items.sum {|item| item.price}
end
end
def total_price
@items.sum {|item| item.price}
end
+ def total_items
+ @items.sum {|item| item.quantity}
+ end
+
end
end