Ask A Question

Notifications

You’re not receiving notifications from this thread.

Storing measurements for users in metric and english measurement systems

Matthew Graham asked in Databases

I am rebuilding an application that stores data for search and recovery divers. Previously, it was for a single team and we used the english measurement systems, however, now that the application is growing to multiple teams and locations users and teams will have the ability to view data in either english or metric system measurements. My question is, do i store all data in one, ie english feet, and then convert each time for metric? The user can change their view preferences at any time. This would mean if a user said the dive was 3m deep, I'd store 9.842519685 and just do the math each time.

[Rails 7.1, Postgresql app]
Thanks for the thoughts.

Reply

The math is fast to do, so that would be fine to convert each time.

You could also use a virtual generated column to do the calculation at the database level. See this lesson: https://gorails.com/episodes/virtual-generated-columns-with-activerecord

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.