small medium large xlarge

09 Apr 2011, 17:38
Scott White (6 posts)

I’ve reached the end of iteration F1 on page 145, and everything is working accept the redirect change to line_items_controller.rb

Here’s my create action from that controller

  # POST /line_items
  # POST /line_items.xml
  def create
    @cart = current_cart
    product = Product.find(params[:product_id])
    @line_item = @cart.add_product(

    respond_to do |format|
        format.html { redirect_to(store_url) }
        format.xml  { render :xml => @line_item,
          :status => :created, :location => @line_item }
        format.html { render :action => "new" }
        format.xml  { render :xml => @line_item.errors,
          :status => :unprocessable_entity }

I’m not getting an error message, but clicking on the “Add to Cart” button is not refreshing the cart in the sidebar. However, if I refresh the page it updates.

Hoping someone can re-direct me to where I’ve made a mistake. Let me know any other code you want to see.

Thanks in advance, Scott

10 Apr 2011, 16:14
Scott White (6 posts)

Nevermind, I restarted the rails server and it started working…not sure why but the server had been running for most of the depot project.


You must be logged in to comment