3 class BelongsToPolymorphicAssociation
< AssociationProxy
#:nodoc:
6 @target = @owner[@reflection.primary_key_name
] = @owner[@reflection.options
[:foreign_type]] = nil
8 @target = (AssociationProxy
=== record
? record
.target
: record
)
10 @owner[@reflection.primary_key_name
] = record
.id
11 @owner[@reflection.options
[:foreign_type]] = record
.class.base_class
.name
.to_s
26 return nil if association_class
.nil?
28 if @reflection.options
[:conditions]
29 association_class
.find(
30 @owner[@reflection.primary_key_name
],
31 :select => @reflection.options
[:select],
32 :conditions => conditions
,
33 :include => @reflection.options
[:include]
36 association_class
.find(@owner[@reflection.primary_key_name
], :select => @reflection.options
[:select], :include => @reflection.options
[:include])
40 def foreign_key_present
41 !@owner[@reflection.primary_key_name
].nil?
45 @owner[@reflection.options
[:foreign_type]] ? @owner[@reflection.options
[:foreign_type]].constantize
: nil