Created
August 19, 2020 12:50
-
-
Save berellevy/2379d3be0072726cc470bd8c87c1b13e 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
class Cart < ApplicationMethod | |
... | |
def make_purchase | |
if cart_items.length > 0 | |
p = Purchase.create(user: self.user) | |
p.cart_items = self.cart_items | |
p.save | |
return p.display_purchase | |
else | |
return {error: "No items to purchase"} | |
end | |
end | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment