Returns whether or not the association is valid and applies any errors to
the parent, self, if it wasn’t. Skips any :autosave
enabled records if they’re marked_for_destruction?
or destroyed.
# File activerecord/lib/active_record/autosave_association.rb, line 260
def association_valid?(reflection, association)
return true if association.destroyed? || association.marked_for_destruction?
unless valid = association.valid?
if reflection.options[:autosave]
association.errors.each do |attribute, message|
attribute = "#{reflection.name}.#{attribute}"
errors[attribute] << message
errors[attribute].uniq!
end
else
errors.add(reflection.name)
end
end
valid
end