I want to generate table with float
data type similar to this decimal
table.
add_column :table_name, :lat, :decimal, {:precision=>10, :scale=>6}
How do I do that properly ? And what would terminal command look like for rails generate model
I want to generate table with float
data type similar to this decimal
table.
add_column :table_name, :lat, :decimal, {:precision=>10, :scale=>6}
How do I do that properly ? And what would terminal command look like for rails generate model
The correct is 'price:decimal{5,2}' or price:decimal{5-2}
rails generate migration AddDetailsToProducts 'price:decimal{5,2}'
as pointed out here
Decimal is better than Float.
You can find why here: https://en.wikipedia.org/wiki/IEEE_floating_point
And in this other SO post:
Float vs Decimal in ActiveRecord
So for me.. your first approach is correct. Use decimal with precision.
BTW i think rails does not support :float with :precision.