Association.build doesn't make children visible immediately

I have a problem with a has_many :through association:

#in class Question
has_many :question_assets, :class_name => “MillionaireQuestionAsset”,
:order => “position”, :dependent => :destroy
has_many :assets, :through => :question_assets, :order =>
“millionaire_question_assets.position”

I have some validations on question which look at the children. In some
other methods i’m building the association by building the join table
entries, like so:

question.question_assets.build(attributes)

(i’m building the join entries because there’s extra info in the join
records which i need to stick in there)

Then when i go to save, the validations kick in. Unfortunately they are
failing because they are testing question.assets, and even though
question now ‘knows’ this it has question_assets (ie the joins) it
doesn’t yet ‘know’ that it has the assets - i need to save and reload
the object in order for it to ‘realise’ that it now has the children
assets. Except that i can’t save it because the validations prevent it
being saved, because as far as the validations are concerned it doesn’t
have any assets. arrghh.

I’m not sure how to deal with this. One option is to make the
validation load up the assets manually, eg something like

assets = self.question_assets.collect(&:asset)

and then test assets. But i just tried this and this breaks some other
tests i have where i’m using

question.assets.build(attributes)

because those tests don’t know about the new question_asset
associations. Ie they only know about the far-side children, they don’t
know about the joins.

Any advice anyone? Is there a way to get the question to ‘refresh’
somehow and realise that it has these assocations before saving?
Obviously doing reload will wipe out all the unsaved stuff so that’s no
good.