instance method _update_row

Ruby on Rails 7.0.10

Since v5.2.8.1 Private

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

_update_row(attribute_names, attempted_action = "update")

No documentation comment.

Parameters

attribute_names req
attempted_action opt = "update"
Source
# File activerecord/lib/active_record/locking/optimistic.rb, line 92
        def _update_row(attribute_names, attempted_action = "update")
          return super unless locking_enabled?

          begin
            locking_column = self.class.locking_column
            lock_attribute_was = @attributes[locking_column]

            update_constraints = _query_constraints_hash

            attribute_names = attribute_names.dup if attribute_names.frozen?
            attribute_names << locking_column

            self[locking_column] += 1

            affected_rows = self.class._update_record(
              attributes_with_values(attribute_names),
              update_constraints
            )

            if affected_rows != 1
              raise ActiveRecord::StaleObjectError.new(self, attempted_action)
            end

            affected_rows

          # If something went wrong, revert the locking_column value.
          rescue Exception
            @attributes[locking_column] = lock_attribute_was
            raise
          end
        end

Defined in activerecord/lib/active_record/locking/optimistic.rb line 92 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Locking::Optimistic

Type at least 2 characters to search.

↑↓ navigate · open · esc close