aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/query_methods.rb
diff options
context:
space:
mode:
authorFlorent Guilleux <florent2@gmail.com>2012-06-16 17:16:10 -0500
committerFlorent Guilleux <florent2@gmail.com>2012-06-16 17:16:10 -0500
commitd62645cfbf53e43eae7ce0cba3781e58bb7a894a (patch)
treea102478d77b023e4c953a766cdcf2d084ab28c16 /activerecord/lib/active_record/relation/query_methods.rb
parentf713bf6e38147f36a77d0372b1908300b8d0bdc4 (diff)
downloadrails-d62645cfbf53e43eae7ce0cba3781e58bb7a894a.tar.gz
rails-d62645cfbf53e43eae7ce0cba3781e58bb7a894a.tar.bz2
rails-d62645cfbf53e43eae7ce0cba3781e58bb7a894a.zip
Add documentation for ActiveRecord::QueryMethods#limit [ci skip]
Diffstat (limited to 'activerecord/lib/active_record/relation/query_methods.rb')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb10
1 files changed, 7 insertions, 3 deletions
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