Valery Kvon wrote in post #1047982:
> Show us the code of LineItem class.
>
>
> This method raises the error on a new instance. To avoid it, it must
> return BigDec anytime. In your case product.price is nil or quantity is
> nil..
>
> def total_price
> product.price * quantity
> end
class LineItem < ActiveRecord::Base
belongs_to :product
belongs_to :cart
def total_price
if product.price
product.price = product.price * quantity
else
0.to_d
end
end
end
this is my model/line item.rb
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.