title: I can't figure out my rails line_items controller create action error?
body: <p>I am getting this error when trying to add a product to a cart: </p>
  
  <pre><code>ActiveRecord::RecordNotFound in LineItemsController#create
  Couldn't find Cart with 'id'=2
  </code></pre>
  
  <p>So something is wrong with the create action, but I'm not sure what it is... Create action:(the gap between @product and quantity isn't there in my actual code, can't get it formatted right.)</p>
  
  <pre><code>def create
    @product = Product.find(params[:product_id])
    @line_item = LineItem.create!(:cart =&gt; current_cart, :product =&gt; @product, 
  
    :quantity=&gt;    1, :unit_price =&gt; @product.price)
    flash[:notice] = "Added #{@product.name} to cart."
    redirect_to cart_url(current_cart)
  </code></pre>
  
  <p>end</p>
  
  <p>current_cart method from application controller:</p>
  
  <pre><code>def current_cart
  session[:cart_id] ||= Cart.create!.id
  @current_cart ||= Cart.find(session[:cart_id])
  end
  </code></pre>
  
  <p>Thanks for the help.</p>