Method: ActiveRecord::Persistence::ClassMethods#_update_record

Defined in:
activerecord/lib/active_record/persistence.rb

#_update_record(values, constraints) ⇒ Object

:nodoc:



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'activerecord/lib/active_record/persistence.rb', line 265

def _update_record(values, constraints) # :nodoc:
  constraints = constraints.map { |name, value| predicate_builder[name, value] }

  default_constraint = build_default_constraint
  constraints << default_constraint if default_constraint

  if current_scope = self.global_current_scope
    constraints << current_scope.where_clause.ast
  end

  um = Arel::UpdateManager.new(arel_table)
  um.set(values.transform_keys { |name| arel_table[name] })
  um.wheres = constraints

  with_connection do |c|
    c.update(um, "#{self} Update")
  end
end