diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-11-20 13:37:54 -0300 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-23 09:51:07 -0800 |
commit | 9f35799221c8a3c06b3f34a38525654b59598cfd (patch) | |
tree | 09faccc6761bbb816c57b7b0b69c8f0df844d31b | |
parent | e2bad8a2e7e020901ddb74c3404a1c339b5a99f9 (diff) | |
download | rails-9f35799221c8a3c06b3f34a38525654b59598cfd.tar.gz rails-9f35799221c8a3c06b3f34a38525654b59598cfd.tar.bz2 rails-9f35799221c8a3c06b3f34a38525654b59598cfd.zip |
Refactor && simplify count_records.
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 6423536fb9..23831e0b08 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -42,11 +42,7 @@ module ActiveRecord # documented side-effect of the method that may avoid an extra SELECT. @target ||= [] and loaded if count == 0 - if @reflection.options[:limit] - count = [ @reflection.options[:limit], count ].min - end - - count + @reflection.options[:limit] ? [@reflection.options[:limit], count].min : count end def has_cached_counter? |