I am having a weird problem
In the form in my view the user can upload multiple files at once. In
there are multiple validations for an Upload, such as being under a
certain filesize or not having absurd dimensions if it’s an image, etc.
The problem is that if one of the uploads fails validation, the Post
object fails validation as well. Previously, I thought I had to specify
validates_associated :uploads in the Post model to get this behavior,
but seems like that is not the case. If one of the uploads fails I get
the error message “Uploads is invalid” in the Post object’s errors,
which prevents the Post and all other Uploads from saving whether or not
they are valid; so basically one bad upload ruins the whole thing. This
is kind of bad since it can take a user a while to upload multiple
files, and I think it’s silly to say “one upload out of ten failed,
start all over” when some of the uploads might be good.
What I would -like- to do is accept as many uploads as possible, having
the Post object fail to save only if zero uploads were valid. Any
invalid uploads get thrown away (although ideally I could somehow keep
their errors stored somewhere [in the Post object?] so I can show the
user what uploads failed and why).