S
Summercool
This is for people who read or have read the Agile Web Development
book by Dave Thomas (Pragmatic Programmers series like for the PickAx
book).
So it seems like with the Depot app in Chapter 8, if there are
thousands of users using the website, there will be thousands or tens
of thousands of CartItem objects in the server machine's RAM.... and the
Cart object contains the array that tells which user has which
CartItem objects...
Now, I tried this to see how many CartItem object there are:
in model/cart_item.rb, i added the class variable @@count
class CartItem
attr_reader roduct, :quantity@@count = 0def initialize(product)
@product = product
@quantity = 1
@@count += 1enddef self.count
@@count
enddef count
@@count
end
and in store.rhtml, i add the following to the LEFT column of the page
Number of CartItem <%= CartItem.count %>
but I tried adding items after items... the count just won't go from 1
to 2, 3, 4, 5, 6 but will just keep on being either 0 or 1. Any
thoughts as to why?
book by Dave Thomas (Pragmatic Programmers series like for the PickAx
book).
So it seems like with the Depot app in Chapter 8, if there are
thousands of users using the website, there will be thousands or tens
of thousands of CartItem objects in the server machine's RAM.... and the
Cart object contains the array that tells which user has which
CartItem objects...
Now, I tried this to see how many CartItem object there are:
in model/cart_item.rb, i added the class variable @@count
class CartItem
attr_reader roduct, :quantity@@count = 0def initialize(product)
@product = product
@quantity = 1
@@count += 1enddef self.count
@@count
enddef count
@@count
end
and in store.rhtml, i add the following to the LEFT column of the page
Number of CartItem <%= CartItem.count %>
but I tried adding items after items... the count just won't go from 1
to 2, 3, 4, 5, 6 but will just keep on being either 0 or 1. Any
thoughts as to why?