I appreciate the reply about to implement the Unit and Measure classes (as 
you call them). I'm already pretty clear on how I want to handle the values 
with units themselves, my questions is more about how best to use these 
Measure instances in a Rails model: storing "unit-ed" values for many 
different fields, in a form that preserves the original values and units, 
and allowing for summary calculations (i.e. in a cached, shared unit like 
metric).

My concern is that both 1-to-1 associations (belongs_to and has_one) 
require the inverse association to be declared on the other side to work 
correctly (unless I'm wrong about that). This class is more of a data type 
than a full-fledged model class, so having to update it with a bogus 
back-association every time I use it in a new field elsewhere in my main 
model classes seems like the wrong approach.

What feels right is something like MongoDB's concept of an embedded 
document, since these Measure objects are really just compound values that 
only ever make sense within the context of a given model instance. I can't 
use Mongo on this project, however, so I'm curious how folks would tackle 
this problem in ActiveRecord.

Dustin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/QR1xGr3pgogJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to