/ Published in: Rails

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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
Comments
