From d62645cfbf53e43eae7ce0cba3781e58bb7a894a Mon Sep 17 00:00:00 2001 From: Florent Guilleux Date: Sat, 16 Jun 2012 17:16:10 -0500 Subject: Add documentation for ActiveRecord::QueryMethods#limit [ci skip] --- activerecord/lib/active_record/relation/query_methods.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index a89d0f3ebf..1fb4cbe1c4 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -71,8 +71,6 @@ module ActiveRecord # Used to indicate that an association is referenced by an SQL string, and should # therefore be JOINed in any query rather than loaded separately. # - # For example: - # # User.includes(:posts).where("posts.name = 'foo'") # # => Doesn't JOIN the posts table, resulting in an error. # @@ -163,7 +161,6 @@ module ActiveRecord # User.order('email DESC').reorder('id ASC').order('name ASC') # # generates a query with 'ORDER BY id ASC, name ASC'. - # def reorder(*args) args.blank? ? self : spawn.reorder!(*args) end @@ -216,6 +213,13 @@ module ActiveRecord self end + # Specifies a limit of records. + # + # User.limit(10) # generated SQL has 'LIMIT 10' + # + # Replaces any existing previous limit. + # + # User.limit(10).limit(20) # generated SQL has 'LIMIT 20' def limit(value) spawn.limit!(value) end -- cgit v1.2.3