aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/association_relation.rb
diff options
context:
space:
mode:
authorLauro Caetano <laurocaetano1@gmail.com>2014-04-14 21:24:31 -0300
committerLauro Caetano <laurocaetano1@gmail.com>2014-04-14 22:00:21 -0300
commit34945e41c24c59268bbde63abfafe20bdc09b775 (patch)
tree95ec397101f7a23e25f03d44af817795e3c73dad /activerecord/lib/active_record/association_relation.rb
parent43f525031ad3f83a04f84e79bbe1de340bf937aa (diff)
downloadrails-34945e41c24c59268bbde63abfafe20bdc09b775.tar.gz
rails-34945e41c24c59268bbde63abfafe20bdc09b775.tar.bz2
rails-34945e41c24c59268bbde63abfafe20bdc09b775.zip
The Association Relation should use `empty?` and `size` from Relation.
968c581ea34b5236af14805e6a77913b1cb36238 have introduced this bug #14744 on Association Relation when the method `empty?` or `size` was called. Example: # Given an author that does have 3 posts, but none of them with the # title 'Some Title' Author.last.posts.where(title: 'Some Title').size # => 3 It was occurring, because the Association Relation had implemented these methods based on `@association`, this way giving wrong results. To fix it, was necessary to remove the methods `empty?` and `size` from Association Relation. It just have to use these methods from Relation. Example: # Given an author that does have 3 posts, but none of them with the # title 'Some Title' Author.last.posts.where(title: 'Some Title').size # => 0 # Now it will return the correct value. Fixes #14744.
Diffstat (limited to 'activerecord/lib/active_record/association_relation.rb')
-rw-r--r--activerecord/lib/active_record/association_relation.rb8
1 files changed, 0 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/association_relation.rb b/activerecord/lib/active_record/association_relation.rb
index 45f1b07f69..5a84792f45 100644
--- a/activerecord/lib/active_record/association_relation.rb
+++ b/activerecord/lib/active_record/association_relation.rb
@@ -9,14 +9,6 @@ module ActiveRecord
@association
end
- def size
- @association.size
- end
-
- def empty?
- @association.empty?
- end
-
def ==(other)
other == to_a
end