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 after_validation_on_create. I have changed it so it works for the time being, but at the moment I'm baffled. 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 there: http://pastie.caboo.se/42937 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?
on 2007-02-25 23:09