diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2013-04-23 09:23:57 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2013-04-23 09:23:57 -0700 |
commit | 7389df139a35436f00876c96d20e81ba23c93f0a (patch) | |
tree | 9ce85c2ec6057aec81acbf330682059d57d50471 /activerecord/lib/active_record/associations | |
parent | 5af29cbde8c10f081bd8216338d0cdb661e23fb3 (diff) | |
download | rails-7389df139a35436f00876c96d20e81ba23c93f0a.tar.gz rails-7389df139a35436f00876c96d20e81ba23c93f0a.tar.bz2 rails-7389df139a35436f00876c96d20e81ba23c93f0a.zip |
Revert "`belongs_to :touch` behavior now touches old association when transitioning to new association" until a proper fix is found for #10197
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 |