diff options
author | Xavier Noria <fxn@hashref.com> | 2013-03-16 12:00:50 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2013-03-16 12:00:50 +0100 |
commit | 9a421aaa8285cf2a7ecb1af370748b0337818930 (patch) | |
tree | a03c40e15b5ef0dabaacd0ac2476531b04088757 | |
parent | 34be80443c76dde393ae5e2b28805bd01605eadc (diff) | |
download | rails-9a421aaa8285cf2a7ecb1af370748b0337818930.tar.gz rails-9a421aaa8285cf2a7ecb1af370748b0337818930.tar.bz2 rails-9a421aaa8285cf2a7ecb1af370748b0337818930.zip |
fixes markup of the CHANGELOG entry from 455d710
-rw-r--r-- | activerecord/CHANGELOG.md | 28 |
1 files 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* |