Banging my head about this one today and I can’t find any information on this in the API…
I have two models… User and PersonRecord. PersonRecord is a model that is shared among several applications and hooked into a completely different database. It contains the personal information about a user. The User model simply contains a username column. These models work together via a belongs_to relationship.
u = User.find 1
Let’s say I have 200 users… I would hate to have to run 200 queries to the second database to grab the other data, so my thought was “Hey, I’ll just serialize that data onto my object and periodically synchronize the data.”
class User < ActiveRecord::Base
serialize :person_record_data, PersonRecord
… more stuff
u.person_record_data = u.person_record
That all works just great… except when I try to get the record back, person_record_data is nil.
I can serialize hashes, arrays, etc just fine… but I can’t seem to serialize ActiveRecord objects… is this a limitation? a bug?
Thanks in advance to anyone who can help me out. The documentation on what is allowed is pretty vague.