small medium large xlarge

Generic-user-small
05 May 2010, 16:43
deco10 (1 post)

Can somebody help me understand the self.from_cart_item() method? Its just not registering in my ol’ brain. The code works and writes to the database just fine.

Thanks!

class LineItem < ActiveRecord::Base belongs_to :order belongs_to :product

def self.from_cart_item(cart_item) li = self.new li.product = cart_item.product li.quantity = cart_item.quantity li.total_price = cart_item.price li end end

You must be logged in to comment