Skip to content

Instantly share code, notes, and snippets.

@jbynum
Created September 22, 2011 19:00
Show Gist options
  • Save jbynum/1235683 to your computer and use it in GitHub Desktop.
Save jbynum/1235683 to your computer and use it in GitHub Desktop.
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