method

add_to_target

add_to_target(record, skip_callbacks = false)
public

No documentation available.

# File activerecord/lib/active_record/associations/collection_association.rb, line 387
      def add_to_target(record, skip_callbacks = false)
        callback(:before_add, record) unless skip_callbacks
        yield(record) if block_given?

        if association_scope.distinct_value && index = @target.index(record)
          @target[index] = record
        else
          @target << record
        end

        callback(:after_add, record) unless skip_callbacks
        set_inverse_instance(record)

        record
      end