Seems pretty simple, but then nothing is.
I have two values:
t.integer "quantity"
t.decimal "unit_price", :precision => 7, :scale => 2
I want to multiply quantity by unit_price in an each (invoice) loop:
invoice.quantity * invoice.unit_price
This causes the following error:
undefined method `*' for nil:NilClass
Do I have to convert the values first or is there something trivial I’m missing?
Thanks
Is returning
nil.You can tell by the error message
You are trying to execute the method
*on an instance ofNilClassCheck this out as an example