From 0859779d6f1cadfec12f1112c80382658466ab7d Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Thu, 16 Mar 2006 02:10:11 +0000 Subject: Allow :dependent options to be used with polymorphic joins. #3820 [Rick Olson] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3881 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/reflection.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/reflection.rb') diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 32e812a86a..e54e38e184 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -118,10 +118,11 @@ module ActiveRecord def primary_key_name return @primary_key_name if @primary_key_name - - case macro - when :belongs_to + case + when macro == :belongs_to @primary_key_name = options[:foreign_key] || class_name.foreign_key + when options[:as] + @primary_key_name = options[:foreign_key] || "#{options[:as]}_id" else @primary_key_name = options[:foreign_key] || active_record.name.foreign_key end -- cgit v1.2.3