instance method upsert

Ruby on Rails 7.1.6

Since v6.0.6 Last seen in v7.1.6

Available in: v6.0.6 v6.1.7.10 v7.0.10 v7.1.6

Signature

upsert(attributes, **kwargs)

Updates or inserts (upserts) a single record into the database in a single SQL INSERT statement. It does not instantiate any models nor does it trigger Active Record callbacks or validations. Though passed values go through Active Record’s type casting and serialization.

See #upsert_all for documentation.

Parameters

attributes req
kwargs keyrest
Source
# File activerecord/lib/active_record/persistence.rb, line 252
      def upsert(attributes, **kwargs)
        upsert_all([ attributes ], **kwargs)
      end

Defined in activerecord/lib/active_record/persistence.rb line 252 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Persistence::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close