diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-18 19:28:09 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-18 19:28:09 -0500 |
commit | 5111ec446bedbc8d0ff6ef11de1000047e0edff5 (patch) | |
tree | fcaa49ad2623724ddebd12e43baf18b72df0ba15 /activerecord | |
parent | ec430d478a989aef7ad27a1f7251c4c378a08b25 (diff) | |
download | rails-5111ec446bedbc8d0ff6ef11de1000047e0edff5.tar.gz rails-5111ec446bedbc8d0ff6ef11de1000047e0edff5.tar.bz2 rails-5111ec446bedbc8d0ff6ef11de1000047e0edff5.zip |
add CollectionProxy#include? documentation
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 40f59f2c77..0131fa3a5b 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -177,6 +177,19 @@ module ActiveRecord # pet.group == 'cats' # end # # => true + + ## + # :method: include? + # Returns true if the given object is present in the collection. + # + # class Person < ActiveRecord::Base + # has_many :pets + # end + # + # person.pets # => [#<Pet id: 20, name: "Snoop">] + # + # person.pets.include?(Pet.find(20)) # => true + # person.pets.include?(Pet.find(21)) # => false delegate :select, :find, :first, :last, :build, :create, :create!, :concat, :replace, :delete_all, :destroy_all, :delete, :destroy, :uniq, |