Ви не можете вибрати більше 25 тем
Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
|
- class Cart < ApplicationRecord
- has_many :line_items, dependent: :destroy
-
- def add_product(product)
- 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
- current_item
- end
- end
|