validates_format_of

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

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.

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.

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!!