small medium large xlarge

Generic-user-small
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(product.id)

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

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

Generic-user-small
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.

-Scott

You must be logged in to comment