module ActiveRecord::AutosaveAssociation

monkey-patch

Public Instance Methods

associated_records_to_validate_or_save(association, new_record, autosave) click to toggle source

Returns the record for an association collection that should be validated or saved. If autosave is false only new records will be returned, unless the parent is/was a new record itself.

# File lib/deep_unrest.rb, line 15
def associated_records_to_validate_or_save(association,
                                           new_record,
                                           autosave)
  if new_record || autosave
    association&.target
  else
    association.target.find_all(&:new_record?)
  end
end