method

_create_record

Importance_0
Ruby on Rails latest stable (v7.1.3.2) - 0 notes - Class: CollectionAssociation
_create_record(attributes, raise = false, &block) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/associations/collection_association.rb, line 346
        def _create_record(attributes, raise = false, &block)
          unless owner.persisted?
            raise ActiveRecord::RecordNotSaved.new("You cannot call create unless the parent is saved", owner)
          end

          if attributes.is_a?(Array)
            attributes.collect { |attr| _create_record(attr, raise, &block) }
          else
            record = build_record(attributes, &block)
            transaction do
              result = nil
              add_to_target(record) do
                result = insert_record(record, true, raise) {
                  @_was_loaded = loaded?
                }
              end
              raise ActiveRecord::Rollback unless result
            end
            record
          end
        end
Register or log in to add new notes.