Try telling ruby that a variable contains the value 300.00, it will
say:
a = 300.00
=> 300.0
a
=> 300.0
And there's your answer. You will have to tell Ruby that this is a so-
called "double". to_d didn't work in my local environment, but that
Ruby version is quite old. Try to to find how to convert your object
into a double.
Hope this helps!
Kind regards,
Jaap Haagmans
w. http://www.relywebsolutions.nl
11175
(-- --)
August 8, 2009, 2:05pm
2
jhaagmans wrote:
You will have to tell Ruby that this is a so-
called "double".
I don't think that will help at all. However, I believe there's a
method called validates_numericality_of that may be of use...
Also, [0-9] is never necessary. Just use \d .
Best,
Right, as I said, I've never done something like it, but at least we
know what's wrong.
Con
(Con)
August 9, 2009, 4:52pm
4
jhaagmans wrote:
You will have to tell Ruby that this is a so-
called “double”.
I don’t think that will help at all. However, I believe there’s a
method called validates_numericality_of that may be of use…
validates_numericality_of only determines whether something is numeric
Also, [0-9] is never necessary. Just use \d .
[0-9] is just another way of writing \d. Thus, it’s really a personal preface and
both are clearly documented in the PixAxe.
11155
(-- --)
March 16, 2010, 6:48pm
5
Thanks my friend whit this my :price field is correct!
validates_format_of :precio, :with => /\A[0-9]{1,5}\.[0-9]{1,2}\Z/,
:message => ""
I love Rails!!