Take the 2-minute tour ×

I've been looking all over, and really just need a definitive answer to ride on. I'm going to have an object that contains percentages compiled from other objects, the point here is, what's the standard for representing a percentage in rails, without it getting broken in data migrations and things like that.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

If you use :decimal as the type, they'll get converted into BigDecimals. Be sure to specify :precision and :scale in your migration, lest Rails decide that you really wanted an integer instead.

share|improve this answer
So for a percentage field that I want to have a maximum of 1.00 (eg 100%) then scale=2(eg for .00), do I set precision as 3? –  Evolve Aug 6 '12 at 7:22
For others who come here wondering, Precision is the total amount of digits, scale is the number of digits right of the decimal point –  Evolve Aug 6 '12 at 7:25
add comment

I use :float often and works without problem for me.

share|improve this answer
add comment

Your Answer


