Forum: Ruby on Rails validated_associated -- how do I assign invalid collection?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2837408ba0375c40b235f0a5a5107d37?d=identicon&s=25 Doug Livesey (biot023)
on 2006-06-09 14:28
Hi -- if I have a class that declares 'validates_associated' on a number
of other classes, is it supposed to be relatively easy to replace a
collection of them?
Not to overwrite them in the DB, but simply to assign them to their
retrieval method, so that they can be included as part of the owning
class' validation.
I mean like:

children_with_potential_errors =
    Child.update(params[:child].keys, params[:child].values)
parent.children = children_with_potential_errors
if parent.update_attributes(params[:parent])
  ...
else
  ...
end

I have a class like Parent above, that has three collections
(one-to-many) like Child above, yet I am having a very diffcult time
trying to get code like that I have outlined working.
Can anyone think of anything I could be missing that might allow me to
replace the collection, or maybe someone is aware of a reason that I
cannot do this?
(If the latter, why would 'validates_asssociated' exist?)
Any & all help is *very* gratefully received -- I've been stuck on this
for days!
Cheers,
   doug.
This topic is locked and can not be replied to.