Created
September 22, 2011 19:00
-
-
Save jbynum/1235683 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 add_product(product) | |
current_item = line_items.find_by_mnetid(product[:mnetid]) | |
if current_item | |
current_item.errors[:base] << "This is already in your cart" | |
#raise "This is already in your cart" | |
return false | |
else | |
current_item = line_items.build( | |
:mnetid => product[:mnetid], | |
:title => product[:title], | |
:artist => product[:artist], | |
:price => product[:price].to_f | |
) | |
end | |
current_item | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment