Permalink
Browse files

Add documentation for ActiveRecord::QueryMethods#limit [ci skip]

  • Loading branch information...
1 parent f713bf6 commit d62645cfbf53e43eae7ce0cba3781e58bb7a894a Florent Guilleux committed Jun 16, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 activerecord/lib/active_record/relation/query_methods.rb
@@ -71,8 +71,6 @@ def preload!(*args)
# 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 @@ def order!(*args)
# 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 @@ def having!(opts, *rest)
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

0 comments on commit d62645c

Please sign in to comment.