Sha256: 19bcf2a5a63cc0cf3880b64240b2e8aa8cec0ddf2b22fa73b2806d83b3f55c3e
Contents?: true
Size: 528 Bytes
Versions: 7
Compression:
Stored size: 528 Bytes
Contents
class LineItem < ActiveRecord::Base belongs_to :order belongs_to :product belongs_to :variation validates_presence_of :product validates_numericality_of :quantity validates_numericality_of :price def self.from_cart_item(cart_item) line_item = self.new line_item.product = cart_item.product line_item.quantity = cart_item.quantity line_item.price = cart_item.price line_item.variation = cart_item.variation line_item end def total self.price * self.quantity end end
Version data entries
7 entries across 7 versions & 2 rubygems