I want to complete a cart part in a site. The first time i add items into the cart it is ok, but the second time with the same items i would get a error:
undefined method `+' for nil:NilClass
Extracted source (around line #19):
current_item = line_items.find_by_product_id(product_id)
if current_item
current_item.quantity += 1
else
current_item = line_items.build(product_id: product_id)
end
What is wrong?
Thanks.