Class: ActiveRecord::Associations::HasOneThroughAssociation
- Inherits:
-
HasManyThroughAssociation
- Object
- AssociationProxy
- AssociationCollection
- HasManyAssociation
- HasManyThroughAssociation
- ActiveRecord::Associations::HasOneThroughAssociation
- Defined in:
- lib/active_record/associations/has_one_through_association.rb
Instance Method Summary collapse
Methods inherited from HasManyThroughAssociation
#count, #create, #create!, #initialize, #size
Methods inherited from HasManyAssociation
Methods inherited from AssociationCollection
#<<, #any?, #build, #clear, #create, #create!, #delete, #delete_all, #destroy_all, #empty?, #first, #include?, #initialize, #last, #length, #replace, #reset, #size, #sum, #to_ary, #uniq
Methods inherited from AssociationProxy
#===, #aliased_table_name, #conditions, #initialize, #inspect, #loaded, #loaded?, #proxy_owner, #proxy_reflection, #proxy_respond_to?, #proxy_target, #reload, #reset, #respond_to?, #target, #target=
Constructor Details
This class inherits a constructor from ActiveRecord::Associations::HasManyThroughAssociation
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveRecord::Associations::AssociationCollection
Instance Method Details
#create_through_record(new_value) ⇒ Object
nodoc:
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/active_record/associations/has_one_through_association.rb', line 5 def create_through_record(new_value) #nodoc: klass = @reflection.through_reflection.klass current_object = @owner.send(@reflection.through_reflection.name) if current_object klass.destroy(current_object) @owner.clear_association_cache end @owner.send(@reflection.through_reflection.name, klass.send(:create, construct_join_attributes(new_value))) end |