Method: ActiveRecord::Locking::Optimistic::ClassMethods#initialize_attributes

Defined in:
lib/active_record/locking/optimistic.rb

#initialize_attributes(attributes) ⇒ Object

If the locking column has no default value set, start the lock version at zero. Note we can’t use locking_enabled? at this point as @attributes may not have been initialized yet.



173
174
175
176
177
178
179
# File 'lib/active_record/locking/optimistic.rb', line 173

def initialize_attributes(attributes) #:nodoc:
  if attributes.key?(locking_column) && lock_optimistically
    attributes[locking_column] ||= 0
  end

  attributes
end