Class: ActiveRecord::Associations::HasManyAssociation

Inherits:
CollectionAssociation show all
Defined in:
activerecord/lib/active_record/associations/has_many_association.rb

Overview

This is the proxy that handles a has many association.

If the association has a :through option further specialization is provided by its child HasManyThroughAssociation.

Direct Known Subclasses

HasManyThroughAssociation

Instance Attribute Summary

Attributes inherited from CollectionAssociation

#proxy

Attributes inherited from Association

#owner, #reflection, #target

Instance Method Summary collapse

Methods inherited from CollectionAssociation

#add_to_target, #any?, #build, #concat, #count, #create, #create!, #delete, #delete_all, #delete_all_on_destroy, #destroy, #destroy_all, #empty?, #find, #first, #ids_reader, #ids_writer, #include?, #initialize, #last, #length, #load_target, #many?, #reader, #replace, #reset, #select, #size, #sum, #transaction, #uniq, #writer

Methods inherited from Association

#aliased_table_name, #association_scope, #initialize, #interpolate, #klass, #load_target, #loaded!, #loaded?, #reload, #reset, #reset_scope, #scoped, #set_inverse_instance, #stale_target?, #target_scope

Constructor Details

This class inherits a constructor from ActiveRecord::Associations::CollectionAssociation

Instance Method Details

#insert_record(record, validate = true, raise = false) ⇒ Object

:nodoc:



10
11
12
13
14
15
16
17
18
# File 'activerecord/lib/active_record/associations/has_many_association.rb', line 10

def insert_record(record, validate = true, raise = false)
  set_owner_attributes(record)

  if raise
    record.save!(:validate => validate)
  else
    record.save(:validate => validate)
  end
end