insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [], returning: nil) public

Executes an INSERT query and returns the new record’s ID

id_value will be returned unless the value is nil, in which case the database will attempt to calculate the last inserted id and return that value.

If the next id was calculated in advance (as in Oracle), it should be passed in as id_value. Some adapters support the `returning` keyword argument which allows defining the return value of the method: `nil` is the default value and maintains default behavior. If an array of column names is passed - an array of is returned from the method representing values of the specified columns from the inserted row.

Show source
Register or log in to add new notes.