diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-11-29 12:51:31 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-11-29 12:51:31 -0500 |
commit | 61a7a9f38bfce21bbeb1dd09efabc4f1002cc00d (patch) | |
tree | 57ea9fc8092ab2eb9d3b68577428b25ef1d98668 /activerecord/lib/active_record | |
parent | 97b95c3efb12d4afe11a73ced18d0b0ad906efdb (diff) | |
download | rails-61a7a9f38bfce21bbeb1dd09efabc4f1002cc00d.tar.gz rails-61a7a9f38bfce21bbeb1dd09efabc4f1002cc00d.tar.bz2 rails-61a7a9f38bfce21bbeb1dd09efabc4f1002cc00d.zip |
add documentation to CollectionProxy#empty?
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index e444b0ed83..d57fa40b91 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -718,7 +718,12 @@ module ActiveRecord @association.length end - # Returns +true+ if the collection is empty. + # Returns +true+ if the collection is empty. If the collection has been + # loaded or the <tt>:counter_sql</tt> option is provided, it is equivalent + # to <tt>collection.size.zero?</tt>. If the collection has not been loaded, + # it is equivalent to <tt>collection.exists?</tt>. If the collection has + # not already been loaded and you are going to fetch the records anyway it + # is better to check <tt>collection.length.zero?</tt>. # # class Person < ActiveRecord::Base # has_many :pets |