Hello

I've encountered a little problem with zeros using the decimal data

type

Specifying a scale of 3 and inserting a number with 3 zeros after the

point (for example 12345.000) it gets correctly stored in the

database, but rails insists to show me the number only with the first

zero after the point (12345.0)

There is a way to tell rails to not truncate at the first zero?

You can use sprintf to always force printing up to 3 decimal places,

eg

sprintf "%.3f", the_number

Or even better: number_with_precision

http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#M001687

Best regards

Peter De Berdt

That should do the trick, i'll try later

Thank you very much

Luca

Unfortunately this work only in the views, my program has to generate

a text file, and in the file the number is still truncated

I need to find another solution

Luca

The short, quick way to do it in any context is with plain Ruby:

"%.03f" % value

--Matt Jones