i tried refactoring my destroy method now its working fine but my second 
issue is when i add item to the cart at first attemp it returns to that 
error again but returning to the product list it worked fine im just 
wondering if my add_product is code is ok?

def add_product(product_id)
    current_item = line_items.where(:product_id => product_id).first

     if current_item
        current_item.quantity = current_item.quantity.to_i + 1
      else
        current_item = LineItem.new(:product_id=>product_id)
        line_items << current_item
      end
        current_item
   end

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to