I'd also implement 'address' with a one to one relationship, in fact I have quite regularly, I wouldn't consider using composed_of for an address 'best practise'.
I'd say the O'Reilly authors were simply struggling for a use case for composed_of. A less-strange case is for multiple currency support. You probably don't want to have a 'prices' table, so use some composition.
by Michael Koziarski — Dec 25
I'd also implement 'address' with a one to one relationship, in fact I have quite regularly, I wouldn't consider using composed_of for an address 'best practise'.
I'd say the O'Reilly authors were simply struggling for a use case for composed_of. A less-strange case is for multiple currency support. You probably don't want to have a 'prices' table, so use some composition.
composed_of :price, :class_name => "Money", :mapping => [%w(price amount), %w(currency currency)]