search for: belongstoassociat

Displaying 1 result from an estimated 1 matches for "belongstoassociat".

2008 May 07
1
Assigning to the foreign key on a belongs_to association
.....7135e50 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1094,6 +1094,13 @@ module ActiveRecord instance_variable_set(ivar, new_value.nil? ? nil : association) end + if association_proxy_class == BelongsToAssociation + define_method("#{reflection.primary_key_name}=") do | target_id| + instance_variable_set(ivar, nil) + self["#{reflection.primary_key_name}"] = target_id + end + end + define_method("set_#{reflection.na...