diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-03-16 02:10:11 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-03-16 02:10:11 +0000 |
commit | 0859779d6f1cadfec12f1112c80382658466ab7d (patch) | |
tree | 1f74aa94a49d8c73340468632d2ef1ecda85e64d /activerecord/lib/active_record/reflection.rb | |
parent | bf39c39d88712905a18b7be64a80ecc008719e34 (diff) | |
download | rails-0859779d6f1cadfec12f1112c80382658466ab7d.tar.gz rails-0859779d6f1cadfec12f1112c80382658466ab7d.tar.bz2 rails-0859779d6f1cadfec12f1112c80382658466ab7d.zip |
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
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 7 |
1 files changed, 4 insertions, 3 deletions
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 |