aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-01-01 18:52:48 +0000
committerAaron Patterson <aaron.patterson@gmail.com>2011-01-03 16:24:31 -0800
commitc47f802d0e7b0156512f197887d6e9bda6d0f269 (patch)
tree126e6c305f43ae4d5a48cc94cb01b5aa1c2cc1a7 /activerecord/lib/active_record/associations
parentd18a27031f8794b0134645eb0d62ec16653ac537 (diff)
downloadrails-c47f802d0e7b0156512f197887d6e9bda6d0f269.tar.gz
rails-c47f802d0e7b0156512f197887d6e9bda6d0f269.tar.bz2
rails-c47f802d0e7b0156512f197887d6e9bda6d0f269.zip
Have a proper AssociationReflection#foreign_type method rather than using options[:foreign_type]
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb6
-rw-r--r--activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb2
-rw-r--r--activerecord/lib/active_record/associations/through_association.rb4
3 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb b/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
index 46adc048b8..4608ffad67 100644
--- a/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
+++ b/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
@@ -7,7 +7,7 @@ module ActiveRecord
target_id = @target.send(@reflection.association_primary_key).to_s
foreign_key = @owner.send(@reflection.foreign_key).to_s
target_type = @target.class.base_class.name
- foreign_type = @owner.send(@reflection.options[:foreign_type]).to_s
+ foreign_type = @owner.send(@reflection.foreign_type).to_s
target_id != foreign_key || target_type != foreign_type
else
@@ -19,7 +19,7 @@ module ActiveRecord
def replace_keys(record)
super
- @owner[@reflection.options[:foreign_type]] = record && record.class.base_class.name
+ @owner[@reflection.foreign_type] = record && record.class.base_class.name
end
def different_target?(record)
@@ -31,7 +31,7 @@ module ActiveRecord
end
def target_klass
- type = @owner[@reflection.options[:foreign_type]]
+ type = @owner[@reflection.foreign_type]
type && type.constantize
end
diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
index 1e5149d80f..3fea24ebf8 100644
--- a/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
+++ b/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
@@ -228,7 +228,7 @@ module ActiveRecord
second_key = source_reflection.association_foreign_key
jt_conditions <<
- join_table[reflection.source_reflection.options[:foreign_type]].
+ join_table[reflection.source_reflection.foreign_type].
eq(reflection.options[:source_type])
else
second_key = source_reflection.foreign_key
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb
index c78f5d969f..6536fb44b2 100644
--- a/activerecord/lib/active_record/associations/through_association.rb
+++ b/activerecord/lib/active_record/associations/through_association.rb
@@ -71,7 +71,7 @@ module ActiveRecord
@reflection.klass.primary_key
source_primary_key = @reflection.source_reflection.foreign_key
if @reflection.options[:source_type]
- column = @reflection.source_reflection.options[:foreign_type]
+ column = @reflection.source_reflection.foreign_type
conditions <<
right[column].eq(@reflection.options[:source_type])
end
@@ -105,7 +105,7 @@ module ActiveRecord
}
if @reflection.options[:source_type]
- join_attributes.merge!(@reflection.source_reflection.options[:foreign_type] => associate.class.base_class.name)
+ join_attributes.merge!(@reflection.source_reflection.foreign_type => associate.class.base_class.name)
end
if @reflection.through_reflection.options[:conditions].is_a?(Hash)