File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -129,7 +129,8 @@ def increase_inventory(itemizable_array)
129129 # Locate the storage box for the item, or create a new storage box for it
130130 inventory_item = inventory_items . find_or_create_by! ( item_id : item_hash [ :item_id ] )
131131 # Increase the quantity-on-record for that item
132- inventory_item . increment! ( :quantity , item_hash [ :quantity ] . to_i )
132+ new_quantity = inventory_item . quantity + item_hash [ :quantity ] . to_i
133+ inventory_item . update! ( quantity : new_quantity )
133134 # Record in the log that this has occurred
134135 log [ item_hash [ :item_id ] ] = "+#{ item_hash [ :quantity ] } "
135136 end
@@ -181,7 +182,8 @@ def decrease_inventory(itemizable_array)
181182 # captured by the previous block.
182183 inventory_item = inventory_items . find_by ( item_id : item_hash [ :item_id ] )
183184 # Reduce the inventory box quantity
184- inventory_item . decrement! ( :quantity , item_hash [ :quantity ] )
185+ new_quantity = inventory_item . quantity - item_hash [ :quantity ]
186+ inventory_item . update ( quantity : new_quantity )
185187 # Record in the log that this has occurred
186188 log [ item_hash [ :item_id ] ] = "-#{ item_hash [ :quantity ] } "
187189 end
You can’t perform that action at this time.
0 commit comments