small medium large xlarge

Generic-user-small
22 May 2011, 10:28
Simon (2 posts)

Hi

I’ve been working my way through the book and I’m stuck on page 124. I’ve added in the code below.

Now when I test it, instead of adding a new item to the existing cart it creates a new cart each time. Could anyone give me any pointers? I’ve checked the code through the book a couple of times and can’t see anything obvious I’ve missed.

Thanks

Your Pragmatic Cart

    <% @cart.line_items.each do |item| %>
  • <%= item.product.title %>
  • <% end %>
Generic-user-small
22 May 2011, 16:22
Simon (2 posts)

I’ve copied the sample code from depot_f and all seems well. Still frustrating not knowing where I went wrong.

Generic-user-small
26 Jun 2011, 03:54
Dan Miller (1 post)

I copied the same code from depot_f and the problem is still persisting for me. Totally bizarre. I’m sure the solution is right in front of me but it is getting late…

Generic-user-small
26 Jun 2011, 20:35
Francesco Pessolano (1 post)

I have exactly the same problem. At the end of task D, adding to cart fails due to an error on the line_item create method.

Generic-user-small
22 Jul 2011, 16:03
Martin Crockett (1 post)

The problem may be related to the product.rb (page 120, PDF version).

If you remove the private method block, the example works. Note: this is the case in the downloadable code, not the code in the book version.

Hope this helps.

Generic-user-small
02 Aug 2011, 14:17
Thomas Miskiewicz (2 posts)

I have the book version and all I get is:

NoMethodError in LineItemsController#create

undefined method `line_items’ for 6:Fixnum Rails.root: /home/Thomas Miskiewicz/depot

Application Trace | Framework Trace | Full Trace app/controllers/line_items_controller.rb:53:in `create’

Does the autors of the book care? I’m relly not sure how to continue with this book when it’s broken at this early stage and I have no idea how to fix it.

You must be logged in to comment