-
-
Save benphelps/a8e5110c432e44a76a0b 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
if stock = @account.stocks.find_by_name(stock.pretty_symbol) | |
if stock.price == price.cents | |
stock.amount += amount | |
else | |
@account.stocks << Stock.new(name: stock.pretty_symbol, price: price.cents, amount: amount) | |
end | |
else | |
@account.stocks << Stock.new(name: stock.pretty_symbol, price: price.cents, amount: amount) | |
end | |
@account.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment