Flowdock
method

insert

Importance_0
Ruby on Rails latest stable (v5.2.3) - 0 notes - Class: ActiveRecord::Relation

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v5.1.7) is shown here.

These similar methods exist in v5.2.3:

insert(values) public

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/relation.rb, line 36
    def insert(values) # :nodoc:
      primary_key_value = nil

      if primary_key && Hash === values
        primary_key_value = values[values.keys.find { |k|
          k.name == primary_key
        }]

        if !primary_key_value && klass.prefetch_primary_key?
          primary_key_value = klass.next_sequence_value
          values[arel_attribute(klass.primary_key)] = primary_key_value
        end
      end

      im = arel.create_insert
      im.into @table

      substitutes, binds = substitute_values values

      if values.empty? # empty insert
        im.values = Arel.sql(connection.empty_insert_statement_value)
      else
        im.insert substitutes
      end

      @klass.connection.insert(
        im,
        "SQL",
        primary_key || false,
        primary_key_value,
        nil,
        binds)
    end
Register or log in to add new notes.