Return to Snippet

Revision: 2869
at April 30, 2007 01:01 by winson


Initial Code
  def add(book)
    cur_item = cart_items.find_by_book_id(book.id)
    new_item = cart_items.new(:book_id => book.id, :price => book.price, :amount => 1)
    cur_item ? (cur_item.amount += 1; cur_item.save) : cart_items << new_item
  end

Initial URL

                                

Initial Description

                                

Initial Title
My add book to cart in model

Initial Tags
textmate

Initial Language
Rails