Created
February 11, 2015 08:32
-
-
Save Surgeon/7da2a206bd555f4aa606 to your computer and use it in GitHub Desktop.
app/models/order.rb#138
This file contains hidden or 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
| # ought to | |
| def remove_variants(items_to_delete) | |
| items_to_delete.map do |variant_id, value| | |
| line_item = self.line_items.find(variant_id) | |
| self.line_items.destroy(variant_id).id | |
| end | |
| end | |
| #bad | |
| def remove_variants(items_to_delete) | |
| deleted_items = [] | |
| items_to_delete.each do |variant_id, value| | |
| line_item = self.line_items.find(variant_id) | |
| deleted_items << line_item.id | |
| self.line_items.destroy(variant_id) | |
| end | |
| return deleted_items | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment