I had this same problem and I find this really weird because I was using 
the actual code supplied by the book and was getting the error. When I 
added an extra "end" to the bottom of the file it worked. Can someone 
tell me why this code works:

class Cart
  attr_reader :items

  def initialize
      @items = []
  end

  def add_product(product)
    current_item = @items.find {|item| item.product == product}
    if current_item
      current_item.increment_quantity
    else
      @items << CartItem.new(product)
  end
end
end

It seems to me that there is one too many "end"s here.

Is that right? I am also a newb.

Thanksz!
-- 
Posted via http://www.ruby-forum.com/.
-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to