method
replace
v3.0.0 -
Show latest stable
-
0 notes -
Class: ActiveRecord::Associations::BelongsToPolymorphicAssociation
replace(record)
public
Hide source
# File activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb, line 5 def replace(record) if record.nil? @target = @owner[@reflection.primary_key_name] = @owner[@reflection.options[:foreign_type]] = nil else @target = (AssociationProxy === record ? record.target : record) @owner[@reflection.primary_key_name] = record_id(record) @owner[@reflection.options[:foreign_type]] = record.class.base_class.name.to_s @updated = true end set_inverse_instance(record, @owner) loaded record end