This should just work with ease:
b = Balance.first
b.total = 2.20
b.save #=> 2.2
b #=> 2
Total's table column is an integer :integer. Do I need to set the table as float as the decimal is not registered?
Here is the Rails 4 part; when the form is submitted, I have in the Balance model:
...
before_save :balance_to_float
def balance_to_float
self.total = self.total.to_f
end
...
Sill not getting the float. Have I missed something with Ruby 2.3?
totalcolumn as a float and it should be fineBigDecimalin Ruby andDECIMALin SQL) or use an integer and store the cents (i.e. store2.2as220). The latter is used by the money-rails gem.Money. You can easily write your own wrappers or just use decimal.