Method: ActiveRecord::Core#init_with_attributes

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

#init_with_attributes(attributes, new_record = false) {|_self| ... } ⇒ Object

Initialize an empty model object from attributes. attributes should be an attributes object, and unlike the ‘initialize` method, no assignment calls are made per attribute.

Yields:

  • (_self)

Yield Parameters:



500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'activerecord/lib/active_record/core.rb', line 500

def init_with_attributes(attributes, new_record = false) # :nodoc:
  @new_record = new_record
  @attributes = attributes

  init_internals

  yield self if block_given?

  _run_find_callbacks
  _run_initialize_callbacks

  self
end