Rails works with fields with% point of% transparent, so you do not need to do this explicit conversion. A detail for Rails flutuante de modo
migrations are worked generically as pontos flutuantes
.
Creating the model would look something like:
rails g model ProAttr aggregate_effort:decimal
For this type of field there are extra options ( type modifiers ) as decimal
and precision
.
Where scale
is the total digits that your decimal can have and precision
is the number amount after the decimal point (point in this case).
To generate with these modifiers already would be like this
rails g model ProAttr 'aggregate_effort:decimal{5,2}'
If you need to add a decimal field in the migration, something like this:
add_column :pro_attrs, :aggregate_effort, :decimal, precision: 5, scale: 2
Doing so will get you less headache with floating point fields.