Sha256: aac8cd46ea75d70f34f881de6b60805269e7808f638289949bef27e03a31d49e
Contents?: true
Size: 660 Bytes
Versions: 11
Compression:
Stored size: 660 Bytes
Contents
module ActiveRecord module Acts module ShoppingCartItem module InstanceMethods # # Returns the subtotal, multiplying the quantity times the price of the item. # def subtotal ("%.2f" % (self.quantity * self.price)).to_f end # # Updates the quantity of the item # def update_quantity(new_quantity) self.quantity = new_quantity self.save end # # Updates the price of the item # def update_price(new_price) self.price = new_price self.save end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems