From 08035482858a56963c7694bc7b92308f59272b28 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Fri, 21 Sep 2012 20:49:56 -0500 Subject: update AR::Associations::CollectionProxy#loaded? documentation [ci skip] --- activerecord/lib/active_record/associations/collection_proxy.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index c113957faa..cd3cb1fba0 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -42,6 +42,11 @@ module ActiveRecord @association.load_target end + # Returns +true+ if the association has been loaded, otherwise +false+. + # + # person.pets.loaded? # => false + # person.pets + # person.pets.loaded? # => true def loaded? @association.loaded? end @@ -889,7 +894,7 @@ module ActiveRecord end # Returns a new array of objects from the collection. If the collection - # hasn't been loaded, it fetches the records from the database. + # hasn't been loaded, it fetches the records from the database. # # class Person < ActiveRecord::Base # has_many :pets -- cgit v1.2.3 From e216b00a5ef6038ba227faf3207891c403fb8d1c Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Fri, 21 Sep 2012 22:17:32 -0500 Subject: fix AR::Associations::CollectionProxy#delete broken documentation [ci skip] --- .../active_record/associations/collection_proxy.rb | 25 ++-------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index cd3cb1fba0..e73f940334 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -51,7 +51,6 @@ module ActiveRecord @association.loaded? end - ## # Works in two ways. # # *First:* Specify a subset of fields to be selected from the result set. @@ -109,9 +108,8 @@ module ActiveRecord @association.select(select, &block) end - ## # Finds an object in the collection responding to the +id+. Uses the same - # rules as +ActiveRecord::Base.find+. Returns +ActiveRecord::RecordNotFound++ + # rules as ActiveRecord::Base.find. Returns ActiveRecord::RecordNotFound # error if the object can not be found. # # class Person < ActiveRecord::Base @@ -140,7 +138,6 @@ module ActiveRecord @association.find(*args, &block) end - ## # Returns the first record, or the first +n+ records, from the collection. # If the collection is empty, the first form returns +nil+, and the second # form returns an empty array. @@ -171,7 +168,6 @@ module ActiveRecord @association.first(*args) end - ## # Returns the last record, or the last +n+ records, from the collection. # If the collection is empty, the first form returns +nil+, and the second # form returns an empty array. @@ -202,7 +198,6 @@ module ActiveRecord @association.last(*args) end - ## # Returns a new object of the collection type that has been instantiated # with +attributes+ and linked to this object, but have not yet been saved. # You can pass an array of attributes hashes, this will return an array @@ -231,7 +226,6 @@ module ActiveRecord @association.build(attributes, &block) end - ## # Returns a new object of the collection type that has been instantiated with # attributes, linked to this object and that has already been saved (if it # passes the validations). @@ -262,7 +256,6 @@ module ActiveRecord @association.create(attributes, &block) end - ## # Like +create+, except that if the record is invalid, raises an exception. # # class Person @@ -279,7 +272,6 @@ module ActiveRecord @association.create!(attributes, &block) end - ## # Add one or more records to the collection by setting their foreign keys # to the association's primary key. Since << flattens its argument list and # inserts each record, +push+ and +concat+ behave identically. Returns +self+ @@ -308,7 +300,6 @@ module ActiveRecord @association.concat(*records) end - ## # Replace this collection with +other_array+. This will perform a diff # and delete/add only records that have changed. # @@ -335,7 +326,6 @@ module ActiveRecord @association.replace(other_array) end - ## # Deletes all the records from the collection. For +has_many+ associations, # the deletion is done according to the strategy specified by the :dependent # option. Returns an array with the deleted records. @@ -428,7 +418,6 @@ module ActiveRecord @association.delete_all end - ## # Deletes the records of the collection directly from the database. # This will _always_ remove the records ignoring the +:dependent+ # option. @@ -455,7 +444,6 @@ module ActiveRecord @association.destroy_all end - ## # Deletes the +records+ supplied and removes them from the collection. For # +has_many+ associations, the deletion is done according to the strategy # specified by the :dependent option. Returns an array with the @@ -519,7 +507,7 @@ module ActiveRecord # Pet.find(1, 3) # # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (1, 3) # - # If it is set to :delete_all, all the +records+ are deleted + # If it is set to :delete_all, all the +records+ are deleted # *without* calling their +destroy+ method. # # class Person < ActiveRecord::Base @@ -574,7 +562,6 @@ module ActiveRecord @association.delete(*records) end - ## # Destroys the +records+ supplied and removes them from the collection. # This method will _always_ remove record from the database ignoring # the +:dependent+ option. Returns an array with the removed records. @@ -647,7 +634,6 @@ module ActiveRecord @association.destroy(*records) end - ## # Specifies whether the records should be unique or not. # # class Person < ActiveRecord::Base @@ -666,7 +652,6 @@ module ActiveRecord @association.uniq end - ## # Count all records using SQL. # # class Person < ActiveRecord::Base @@ -684,7 +669,6 @@ module ActiveRecord @association.count(column_name, options) end - ## # Returns the size of the collection. If the collection hasn't been loaded, # it executes a SELECT COUNT(*) query. # @@ -709,7 +693,6 @@ module ActiveRecord @association.size end - ## # Returns the size of the collection calling +size+ on the target. # If the collection has been already loaded, +length+ and +size+ are # equivalent. @@ -733,7 +716,6 @@ module ActiveRecord @association.length end - ## # Returns +true+ if the collection is empty. # # class Person < ActiveRecord::Base @@ -751,7 +733,6 @@ module ActiveRecord @association.empty? end - ## # Returns +true+ if the collection is not empty. # # class Person < ActiveRecord::Base @@ -785,7 +766,6 @@ module ActiveRecord @association.any?(&block) end - ## # Returns true if the collection has more than one record. # Equivalent to collection.size > 1. # @@ -824,7 +804,6 @@ module ActiveRecord @association.many?(&block) end - ## # Returns +true+ if the given object is present in the collection. # # class Person < ActiveRecord::Base -- cgit v1.2.3