Search code examples
ruby-on-railsgmaps4rails

gmaps4rails Float rounding numbers with MySQL


i haved a app with gmaps4rails running in development. The last week i upload to production with MySQL DB. All work cool but, searching address, i try to edit some longitude and latitude values and see the numbers appears rounded when i try to edit some location.

I want to know if i can do something like height or precision in float values? Or if is possible work with decimals in this two fields with gmaps4rails? and how can i move the values i have right now in float to the decimal values?

Thank you for you attention.


Solution

  • You DB fiels are float, I am almost sure it need to be decimal in MySQL for it to work with gmaps4rails. You should perform a migration to modify your fields

    Very important: if you have data you need to protect, you MUST do a full database dump before running the migration, I cannot guarantee you there is no risk to this operation. As you have the situation in your prod server, additional to the DB dump I would advise to import the prod DB to your dev computer and test the migration here.

    The rails migration should look like this:

    change_column :my_table, :latitude, :decimal, precision: 10, scale: 8
    change_column :my_table, :longitude, :decimal, precision: 11, scale: 8
    

    Replace my_table by your table name, and adjust precision and scale as needed