Created
March 20, 2014 15:33
-
-
Save mikecmpbll/9666485 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_inventory | |
if self.item_id_changed? | |
old_item = Item.find(self.item_id_was) | |
old_item.quantityInStock -= self.quantity_was | |
old_item.save! | |
elsif self.quantity_changed? | |
quantity_diff = self.quantity - self.quantity_was | |
self.item.quantityInStock += quantity_diff | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment