aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2013-04-05 00:39:37 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2013-04-05 00:43:16 +0100
commit8f84cdd06f85c65c1949ea227285bbdeb47c5b14 (patch)
treea9aaea9a59bc8813ffd0fe8b49e5ded88c4dfe5d /activerecord/lib/active_record/associations
parent249876b99bd518f93f5a9f8ae6c4ed7d6fb02936 (diff)
downloadrails-8f84cdd06f85c65c1949ea227285bbdeb47c5b14.tar.gz
rails-8f84cdd06f85c65c1949ea227285bbdeb47c5b14.tar.bz2
rails-8f84cdd06f85c65c1949ea227285bbdeb47c5b14.zip
Use inspect when writing the foreign key from the reflection
If we don't use inspect inside the class_eval block then the foreign key is written without quotes causing us to fetch the foreign key value and not the column name.
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/builder/belongs_to.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb
index 579d7789bd..da7e8cda3a 100644
--- a/activerecord/lib/active_record/associations/builder/belongs_to.rb
+++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb
@@ -68,11 +68,11 @@ module ActiveRecord::Associations::Builder
def belongs_to_touch_after_save_or_destroy_for_#{name}
record = #{name}
- foreign_key_field = #{reflection.foreign_key}
+ foreign_key_field = #{reflection.foreign_key.inspect}
if changed_attributes.key?(foreign_key_field)
reflection_klass = #{reflection.klass}
old_foreign_id = changed_attributes[foreign_key_field]
- old_record = reflection_klass.where(foreign_key_field.to_sym => old_foreign_id).first
+ old_record = reflection_klass.where(foreign_key_field => old_foreign_id).first
if old_record
old_record.touch #{options[:touch].inspect if options[:touch] != true}
end