diff options
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/belongs_to.rb | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb index 092230b2f7..c3026dc23c 100644 --- a/activerecord/lib/active_record/associations/builder/belongs_to.rb +++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb @@ -67,19 +67,8 @@ module ActiveRecord::Associations::Builder def add_touch_callbacks(reflection) mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1 def belongs_to_touch_after_save_or_destroy_for_#{name} - foreign_key_field = #{reflection.foreign_key.inspect} - old_foreign_id = attribute_was(foreign_key_field) - - if old_foreign_id - reflection_klass = #{reflection.klass} - old_record = reflection_klass.find_by(reflection_klass.primary_key => old_foreign_id) - - if old_record - old_record.touch #{options[:touch].inspect if options[:touch] != true} - end - end - record = #{name} + unless record.nil? || record.new_record? record.touch #{options[:touch].inspect if options[:touch] != true} end |