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.quantity
>     li.total_price = cart_item.price
>     li
>   end
> end

This all looks correct.  What problem do you think you're having?  Which 
tests are failing?

More importantly, why do you think you need to do this in the first 
place?  Although the method seems correct, it also seems like a strange 
thing for your app to need.

 Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to