small medium large xlarge


Question: Has anyone run into the issue where the cart doesn’t show up when you first go to the page (before adding any products?) For example, add some products to your card, close your browser, reopen it and navigate to the /store index page, the cart won’t be displayed. Add another product and the cart will show up and contain both new product and the one you’ve added previously. Same with the checkout page, no luck getting it to display there either. Any ideas? Thanks!

Question I am stuck on cart creation. I click the Add to Cart button and nothing happens. I tried loading add_to_cart.html.erb directly and rails tells me: No route matches ”/add_to_cart” with {:method=>:get} What am I doing wrong??

Question I am stuck in a different spot. I’ve just completed working through the code and have reached the point of resetting the session (page 114) and now I receive this error: uninitialized constant Cart::CartItem

The trace displayed shows: c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:493:in `const_missing’ app/models/cart.rb:14:in `add_product’ app/controllers/store_controller.rb:11:in `add_to_cart’

Any ideas?

Nevermind – Found the answer in the errata for the book during a search. I had mis-named my cart_item.rb file.

Question: On page 132 is anyone having problems adding the total_price method to the cart model? I’m getting an error, “undefined method ‘total_price’” from the cart view show.html.erb. It’s there, anyone? Answer to question found on forum

Question Sorry – not sure this is in the right place but I could not find the playtime section for this: I tried the image create linking on playtime and was able to do this: <%= link_to(image_tag(product.image_url), line_items_path(:product_id => product, :method => :post )) %> It goes to the line item view… Has anyone got it to goto the cart view like on the button_to link?

Answer I noticed that you’d declared the :method inside the line_items_path object. Give it its own space, like so:

<%= link_to image_tag(product.image_url), 
                  line_items_path(:product_id => product), :method => :post %>

Page History
  • V1: Sam Ruby [almost 6 years ago]