aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/reply.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-05-27 09:28:27 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-05-27 09:28:27 +0900
commitced783fe74ea8683fbc09812ed0e0cadf449a358 (patch)
tree125398dfc6de4749ab8f53a2ba60430293c6af9a /activerecord/test/models/reply.rb
parent6349ad300f2cace625b1c733410c4a39c91028ec (diff)
downloadrails-ced783fe74ea8683fbc09812ed0e0cadf449a358.tar.gz
rails-ced783fe74ea8683fbc09812ed0e0cadf449a358.tar.bz2
rails-ced783fe74ea8683fbc09812ed0e0cadf449a358.zip
Fix inconsistent touching behavior between assigning and unassigning
On belongs_to with `touch: true` association, unassigned object is caused touching, but assigned object is not touched. And also, if primary key is customized, it will touch against the wrong target looked up by the customized key as primary key. This change ensures correctly touching consistently between assigning and unassigning.
Diffstat (limited to 'activerecord/test/models/reply.rb')
-rw-r--r--activerecord/test/models/reply.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb
index bc829ec67f..d1cee58788 100644
--- a/activerecord/test/models/reply.rb
+++ b/activerecord/test/models/reply.rb
@@ -4,7 +4,7 @@ require "models/topic"
class Reply < Topic
belongs_to :topic, foreign_key: "parent_id", counter_cache: true
- belongs_to :topic_with_primary_key, class_name: "Topic", primary_key: "title", foreign_key: "parent_title", counter_cache: "replies_count"
+ belongs_to :topic_with_primary_key, class_name: "Topic", primary_key: "title", foreign_key: "parent_title", counter_cache: "replies_count", touch: true
has_many :replies, class_name: "SillyReply", dependent: :destroy, foreign_key: "parent_id"
end