Sha256: e85ad5581851cc741f68ca109dba4051da5064ef55cc43eca9227c04c3619865
Contents?: true
Size: 699 Bytes
Versions: 3
Compression:
Stored size: 699 Bytes
Contents
class TbCommerce::CartItem < ActiveRecord::Base self.table_name = 'tb_commerce_cart_items' belongs_to :cart, :foreign_key => :tb_commerce_cart_id, :touch => true belongs_to :product_sku, :foreign_key => :tb_commerce_product_sku_id serialize :configuration, Hash # validates :cart, :product_sku, :presence => true validates :quantity, :numericality => {:greater_than => 0} validates :configuration, :length => {:maximum => 1000} before_save :set_product_sku_values def total_price return price * quantity end private def set_product_sku_values if product_sku self.description = product_sku.description self.price = product_sku.price end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tb_commerce-0.0.4 | app/models/tb_commerce/cart_item.rb |
tb_commerce-0.0.3 | app/models/tb_commerce/cart_item.rb |
tb_commerce-0.0.2 | app/models/tb_commerce/cart_item.rb |