aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/association_proxy.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-02-12 18:03:43 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-02-12 18:03:43 +0000
commita32a9863640dbd7a74b251e5467f90d134396110 (patch)
tree9749cf28832ec403227a8dc92bf06e336bfb5a58 /activerecord/lib/active_record/associations/association_proxy.rb
parentb230004897770ff8e29590263ddd6416b728af3a (diff)
downloadrails-a32a9863640dbd7a74b251e5467f90d134396110.tar.gz
rails-a32a9863640dbd7a74b251e5467f90d134396110.tar.bz2
rails-a32a9863640dbd7a74b251e5467f90d134396110.zip
save polymorphic joins from the has_many|one association (closes #3812) [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3586 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations/association_proxy.rb')
-rw-r--r--activerecord/lib/active_record/associations/association_proxy.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb
index c62c042ab2..a4fc85b15e 100644
--- a/activerecord/lib/active_record/associations/association_proxy.rb
+++ b/activerecord/lib/active_record/associations/association_proxy.rb
@@ -74,6 +74,15 @@ module ActiveRecord
@owner.send(:extract_options_from_args!, args)
end
+ 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"] = ActiveRecord::Base.send(:class_name_of_active_record_descendant, @owner.class).to_s
+ else
+ record[@reflection.primary_key_name] = @owner.id unless @owner.new_record?
+ end
+ end
+
def merge_options_from_reflection!(options)
options.reverse_merge!(
:group => @reflection.options[:group],