Re: [Rails] Using self. Can you newbify this for me?

2010-05-05 Thread Rob Biedenharn
On May 5, 2010, at 3:21 PM, dev wrote: For some reason I am tripping up on the use of self and new. 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.quan

Re: [Rails] Using self. Can you newbify this for me?

2010-05-05 Thread Joshua Martin
I don't know for sure because I haven't encountered a situation where I'd need to do things like this... But I'll give it a shot - I'm open to corrections.. class LineItem < ActiveRecord::Base belongs_to :order belongs_to :product def self.from_cart_item(cart_item) li = ne

[Rails] Using self. Can you newbify this for me?

2010-05-05 Thread dev
For some reason I am tripping up on the use of self and new. 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.