Some more information might help :) This is how I create the new object.
@product = Product.new
@product.name = params[:product][:name]
@product.price = params[:product][:price].to_money
@product.save
So, correct me if I''m wrong, the price parameter gets converted to a
money object straight away (before validation is triggered). If you
enter, for example, "abcd" into the price param, when the .to_money
method is called, the money object will be 0.00.
The problem is that if someone enters 1.256 then the price ends being
1.26 because the money object automatically rounds up the value. So, I
need to validate the parameter before it gets converted into a money
object. I thought I may be able to use <field>_before_type_cast, but
this doesn''t exist for the money object.
Any ideas would be appreciated.
Cheers,
Jord
--
Posted via http://www.ruby-forum.com/.