aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-06-22 22:15:27 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-06-22 22:15:27 +0530
commit35ee8fa3d8b3ad49179f86af2bec2e53af335ac9 (patch)
tree5929e772a461c683c54c1fd66b303516e5d0df33 /activerecord/lib/active_record/relation
parentfb8cf55868d555b7f06215db5976c8aaf083d30b (diff)
parent6285675db1cf983ba6c15442aedb457c8041f5ee (diff)
downloadrails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.tar.gz
rails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.tar.bz2
rails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index e394acfaf2..5e5aca0396 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -73,8 +73,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.
#
@@ -165,7 +163,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
@@ -310,6 +307,11 @@ module ActiveRecord
self
end
+ # Specifies a limit for the number of records to retrieve.
+ #
+ # User.limit(10) # generated SQL has 'LIMIT 10'
+ #
+ # User.limit(10).limit(20) # generated SQL has 'LIMIT 20'
def limit(value)
spawn.limit!(value)
end
@@ -319,6 +321,13 @@ module ActiveRecord
self
end
+ # Specifies the number of rows to skip before returning rows.
+ #
+ # User.offset(10) # generated SQL has "OFFSET 10"
+ #
+ # Should be used with order.
+ #
+ # User.offset(10).order("name ASC")
def offset(value)
spawn.offset!(value)
end
@@ -488,6 +497,9 @@ module ActiveRecord
self
end
+ # Reverse the existing order clause on the relation.
+ #
+ # User.order('name ASC').reverse_order # generated SQL has 'ORDER BY name DESC'
def reverse_order
spawn.reverse_order!
end