Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
列の値の合計を計算したい。例えば:
@items = Item.find_all_by_cart_id(cart)
アイテムには列数量があります。@items 数量の合計が必要です。
これを試して
@items = Item.find_all_by_cart_id(cart).sum(:quantity)
items_quantity = @items.map(&:quantity).sum