Class: ActiveRecord::Associations::BelongsToAssociation

Inherits:
SingularAssociation show all
Defined in:
activerecord/lib/active_record/associations/belongs_to_association.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from AssociationProxy

#target

Instance Method Summary (collapse)

Methods inherited from SingularAssociation

#build, #create, #create!

Methods inherited from AssociationProxy

#===, #aliased_table_name, #initialize, #inspect, #loaded!, #loaded?, #method_missing, #proxy_owner, #proxy_reflection, #reload, #reset, #respond_to?, #scoped, #send, #stale_target?, #to_param

Constructor Details

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveRecord::Associations::AssociationProxy

Instance Method Details

- (Object) replace(record)



5
6
7
8
9
10
11
12
13
14
15
# File 'activerecord/lib/active_record/associations/belongs_to_association.rb', line 5

def replace(record)
  record = check_record(record)

  update_counters(record)
  replace_keys(record)
  set_inverse_instance(record)

  @updated = true if record

  self.target = record
end

- (Boolean) updated?

Returns:

  • (Boolean)


17
18
19
# File 'activerecord/lib/active_record/associations/belongs_to_association.rb', line 17

def updated?
  @updated
end