Forum: Ruby on Rails validates_associated causing weird results

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
E5a65ac532873648156265207f93589f?d=identicon&s=25 Anonymous Coward (Guest)
on 2007-02-25 23:09
I'd almost think the presence of "validates_associated" is causing the
associated model to run validation twice.  The associated model, Upload,
which handles uploaded files and saves them, is saving each uploaded
file twice in a row.  This doesn't happen if I remove
"validates_associated" from the model it belongs to, or if I have the
model save files during after_create instead of

I have changed it so it works for the time being, but at the moment I'm

Even in the Image model which is a subclass of Upload, thumbnails made
with RMagick are saved twice instead of once.  I have no idea why.

I've pastied everything.  There's really nothing complicated going on

So I'm imagining, although I could be wrong, that validates_associated
is somehow causing validation on the associated Upload to be run twice,
and since it's run twice then similarly so is
after_validation_on_create, which is thus causing files to be written
twice.  Any ideas?
This topic is locked and can not be replied to.