diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-25 22:42:19 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-25 22:42:19 +0000 |
commit | 89c79b8b9537b5ae8a4d3307e719b6ff6acef6f2 (patch) | |
tree | ce2070759e2d5e218aebe76b34cfb7cb821ddbf9 /activerecord/lib/active_record | |
parent | 3aadfcef88e57b3f0a0bde9a2bc05d372e2fd93b (diff) | |
download | rails-89c79b8b9537b5ae8a4d3307e719b6ff6acef6f2.tar.gz rails-89c79b8b9537b5ae8a4d3307e719b6ff6acef6f2.tar.bz2 rails-89c79b8b9537b5ae8a4d3307e719b6ff6acef6f2.zip |
Fix polymorphic has_one associations declared in an abstract class. Closes #8638.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7119 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 18f4580f45..dd7464432a 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1681,7 +1681,7 @@ module ActiveRecord as_extra ] - when reflection.macro == :has_many && reflection.options[:as] + when reflection.options[:as] && [:has_many, :has_one].include?(reflection.macro) " LEFT OUTER JOIN %s ON %s.%s = %s.%s AND %s.%s = %s" % [ table_name_and_alias, aliased_table_name, "#{reflection.options[:as]}_id", @@ -1689,14 +1689,6 @@ module ActiveRecord aliased_table_name, "#{reflection.options[:as]}_type", klass.quote_value(parent.active_record.base_class.name) ] - when reflection.macro == :has_one && reflection.options[:as] - " LEFT OUTER JOIN %s ON %s.%s = %s.%s AND %s.%s = %s " % [ - table_name_and_alias, - aliased_table_name, "#{reflection.options[:as]}_id", - parent.aliased_table_name, parent.primary_key, - aliased_table_name, "#{reflection.options[:as]}_type", - klass.quote_value(reflection.active_record.base_class.name) - ] else foreign_key = options[:foreign_key] || reflection.active_record.name.foreign_key " LEFT OUTER JOIN %s ON %s.%s = %s.%s " % [ |