Does anyone have experience with / can anyone suggest best practices for storing quantities with large variants in magnitude?
For example, an attribute in one of my models is used to store a weight that could be anything from a few micrograms up to a kilogram or more. My assumption is to convert everything to the smallest unit and store it in the database as an integer (since I might lose accuracy with a float?), but it seems weird to be storing kilogram quantities in micrograms..
Is anybody able to suggest a ruby/rails plugin that might help with this kind of behavior, in the more generic sense? In the same way that a 'time' field in a database is converted into a Time
object in ruby, how would I go about best intercepting the database entry -> class attribute
process, converting a field into my class of choice?
Is there a design pattern for storing varying unit magnitudes that I'm just not thinking of?