Method: ActiveRecord::Associations::Association#initialize_attributes

Defined in:
activerecord/lib/active_record/associations/association.rb

#initialize_attributes(record, except_from_scope_attributes = nil) ⇒ Object

:nodoc:



217
218
219
220
221
222
223
224
225
# File 'activerecord/lib/active_record/associations/association.rb', line 217

def initialize_attributes(record, except_from_scope_attributes = nil) # :nodoc:
  except_from_scope_attributes ||= {}
  skip_assign = [reflection.foreign_key, reflection.type].compact
  assigned_keys = record.changed_attribute_names_to_save
  assigned_keys += except_from_scope_attributes.keys.map(&:to_s)
  attributes = scope_for_create.except!(*(assigned_keys - skip_assign))
  record.send(:_assign_attributes, attributes) if attributes.any?
  set_inverse_instance(record)
end