From 9a421aaa8285cf2a7ecb1af370748b0337818930 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 16 Mar 2013 12:00:50 +0100 Subject: [PATCH] fixes markup of the CHANGELOG entry from 455d710 --- activerecord/CHANGELOG.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 79ca34d89d..799a1c1a65 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -2,26 +2,26 @@ * Counter caches on associations will now stay valid when attributes are updated (not just when records are created or destroyed), for example, - when calling +update_attributes+. The following code now works: + when calling `update_attributes`. The following code now works: - class Comment < ActiveRecord::Base - belongs_to :post, counter_cache: true - end + class Comment < ActiveRecord::Base + belongs_to :post, counter_cache: true + end - class Post < ActiveRecord::Base - has_many :comments - end + class Post < ActiveRecord::Base + has_many :comments + end - post = Post.create - comment = Comment.create + post = Post.create + comment = Comment.create - post.comments << comment - post.save.reload.comments_count # => 1 - comment.update_attributes(:post_id => nil) + post.comments << comment + post.save.reload.comments_count # => 1 + comment.update_attributes(post_id: nil) - post.save.reload.comments_count # => 0 + post.save.reload.comments_count # => 0 - Updating the id of a +belongs_to+ object with the id of a new object will + Updating the id of a `belongs_to` object with the id of a new object will also keep the count accurate. *John Wang* -- GitLab