instance method
association_valid?
Ruby on Rails 3.1.12
Since v2.3.18 PrivateSignature
association_valid?(reflection, record)
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.
Parameters
-
reflectionreq -
recordreq
Source
# File activerecord/lib/active_record/autosave_association.rb, line 285
def association_valid?(reflection, record)
return true if record.destroyed? || record.marked_for_destruction?
unless valid = record.valid?
if reflection.options[:autosave]
record.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
Defined in activerecord/lib/active_record/autosave_association.rb line 285
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AutosaveAssociation