I'm building a Rails application that allows a user to catalogue tires by inputting values into the UI. When I created the tire class , I made it as
class CreateArticles < ActiveRecord::Migration[5.0]
def change
create_table :tires do |t|
t.decimal :price
...
end
end
When I ran the program I realized that I'd neglected to specify the precision and scale of the decimal attribute. This resulted in the program being unable to accept non-integer values and displaying all values appended by .0 Because I was so much farther along on the program, I decided to write another migration to just change price to a float by writing the following migration:
class ChangeTiresToFloat < ActiveRecord::Migration[5.0]
def change
change_column :tires, :price, :float
end
After running db:migrate, there is no change in the behavior of the program. Should this not have made it so that the UI could accept float values?
Edit: Before resorting to making the price column a float value, I did try to fix the decimal value by adding the missing attributes with this migration:
class MoneyDecimalFix < ActiveRecord::Migration[5.0]
def change
change_column :tires, :price, :decimal, :precision => 8, :scale => 2
end
end
After rolling forward the migration, the program's behavior still did not change.