aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-18 15:31:20 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-18 15:31:20 +0000
commitc1611a703c5366d7a85a5283ba1d721cfb5be43a (patch)
tree75445cc8710ded001a6307080a26421875508251 /activerecord/lib
parent515886a5650bfa25e1c450dd31fd4922434a161c (diff)
downloadrails-c1611a703c5366d7a85a5283ba1d721cfb5be43a.tar.gz
rails-c1611a703c5366d7a85a5283ba1d721cfb5be43a.tar.bz2
rails-c1611a703c5366d7a85a5283ba1d721cfb5be43a.zip
Updated documentation here and there
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1210 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb10
-rw-r--r--activerecord/lib/active_record/associations/has_many_association.rb11
2 files changed, 9 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 40eeb481e5..1b25605727 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -193,10 +193,7 @@ module ActiveRecord
# * <tt>collection.clear</tt> - removes every object from the collection. This does not destroy the objects.
# * <tt>collection.empty?</tt> - returns true if there are no associated objects.
# * <tt>collection.size</tt> - returns the number of associated objects.
- # * <tt>collection.find(id)</tt> - finds an associated object responding to the +id+ and that
- # meets the condition that it has to be associated with this object.
- # * <tt>collection.find_all(conditions = nil, orderings = nil, limit = nil, joins = nil)</tt> - finds all associated objects responding
- # criteria mentioned (like in the standard find_all) and that meets the condition that it has to be associated with this object.
+ # * <tt>collection.find</tt> - finds an associated object according to the same rules as Base.find.
# * <tt>collection.build(attributes = {})</tt> - returns a new object of the collection type that has been instantiated
# with +attributes+ and linked to this object through a foreign key but has not yet been saved. *Note:* This only works if an
# associated object already exists, not if its nil!
@@ -205,14 +202,13 @@ module ActiveRecord
# *Note:* This only works if an associated object already exists, not if its nil!
#
# Example: A Firm class declares <tt>has_many :clients</tt>, which will add:
- # * <tt>Firm#clients</tt> (similar to <tt>Clients.find_all "firm_id = #{id}"</tt>)
+ # * <tt>Firm#clients</tt> (similar to <tt>Clients.find :all, :conditions => "firm_id = #{id}"</tt>)
# * <tt>Firm#clients<<</tt>
# * <tt>Firm#clients.delete</tt>
# * <tt>Firm#clients.clear</tt>
# * <tt>Firm#clients.empty?</tt> (similar to <tt>firm.clients.size == 0</tt>)
# * <tt>Firm#clients.size</tt> (similar to <tt>Client.count "firm_id = #{id}"</tt>)
- # * <tt>Firm#clients.find</tt> (similar to <tt>Client.find_on_conditions(id, "firm_id = #{id}")</tt>)
- # * <tt>Firm#clients.find_all</tt> (similar to <tt>Client.find_all "firm_id = #{id}"</tt>)
+ # * <tt>Firm#clients.find</tt> (similar to <tt>Client.find(id, :conditions => "firm_id = #{id}")</tt>)
# * <tt>Firm#clients.build</tt> (similar to <tt>Client.new("firm_id" => id)</tt>)
# * <tt>Firm#clients.create</tt> (similar to <tt>c = Client.new("client_id" => id); c.save; c</tt>)
# The declaration can also include an options hash to specialize the behavior of the association.
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb
index 5e4906c3fb..a775f438f3 100644
--- a/activerecord/lib/active_record/associations/has_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_association.rb
@@ -20,6 +20,7 @@ module ActiveRecord
end
end
+ # DEPRECATED.
def find_all(runtime_conditions = nil, orderings = nil, limit = nil, joins = nil)
if @options[:finder_sql]
records = @association_class.find_by_sql(@finder_sql)
@@ -31,6 +32,11 @@ module ActiveRecord
end
end
+ # DEPRECATED. Find the first associated record. All arguments are optional.
+ def find_first(conditions = nil, orderings = nil)
+ find_all(conditions, orderings, 1).first
+ end
+
# Count the number of associated records. All arguments are optional.
def count(runtime_conditions = nil)
if @options[:counter_sql]
@@ -43,11 +49,6 @@ module ActiveRecord
@association_class.count(sql)
end
end
-
- # Find the first associated record. All arguments are optional.
- def find_first(conditions = nil, orderings = nil)
- find_all(conditions, orderings, 1).first
- end
def find(*args)
options = Base.send(:extract_options_from_args!, args)