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 85
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
options_for_through_record() click to toggle source
# File lib/active_record/mass_assignment_security/associations.rb, line 103
def options_for_through_record
  [through_scope_attributes, without_protection: true]
end