class ActiveRecord::Associations::HasManyThroughAssociation

Private Instance Methods

build_record(attributes, options = {}) click to toggle source
Calls superclass method
# File lib/active_record/mass_assignment_security/associations.rb, line 68
def build_record(attributes, options = {})
  ensure_not_nested

  record = super(attributes, options)

  inverse = source_reflection.inverse_of
  if inverse
    if inverse.macro == :has_many
      record.send(inverse.name) << build_through_record(record)
    elsif inverse.macro == :has_one
      record.send("#{inverse.name}=", build_through_record(record))
    end
  end

  record
end