Method deprecated or moved
This method is deprecated or moved on the latest stable version.
The last existing version (v3.0.9) is shown here.
set_belongs_to_association_for(record)
protected
Assigns the ID of the owner to the corresponding foreign key in
record. If the association is polymorphic the type of the owner is
also set.
# File activerecord/lib/active_record/associations/association_proxy.rb, line 179
def set_belongs_to_association_for(record)
if @reflection.options[:as]
record["#{@reflection.options[:as]}_id"] = @owner.id unless @owner.new_record?
record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s
else
unless @owner.new_record?
primary_key = @reflection.options[:primary_key] || :id
record[@reflection.primary_key_name] = @owner.send(primary_key)
end
end
end