aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMatt Jones <al2o3cr@gmail.com>2012-01-09 11:20:52 -0500
committerVijay Dev <vijaydev.cse@gmail.com>2012-01-11 20:24:22 +0530
commitd0915ac2f99e8e6db81dc4fb5cefe07d98f39fd0 (patch)
treedbb600c8ee4a9c58f648aceffbf40741b5811c8f /activerecord
parent96d4da1719bc10c5ccc039e799e3ce87eab94256 (diff)
downloadrails-d0915ac2f99e8e6db81dc4fb5cefe07d98f39fd0.tar.gz
rails-d0915ac2f99e8e6db81dc4fb5cefe07d98f39fd0.tar.bz2
rails-d0915ac2f99e8e6db81dc4fb5cefe07d98f39fd0.zip
add documentation explaining reorder behavior
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 4ff52d777a..7fd5ad88d9 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -93,6 +93,16 @@ module ActiveRecord
relation
end
+ # Replaces any existing order defined on the relation with the specified order.
+ #
+ # User.order('email DESC').reorder('id ASC') # generated SQL has 'ORDER BY id ASC'
+ #
+ # Subsequent calls to order on the same relation will be appended. For example:
+ #
+ # User.order('email DESC').reorder('id ASC').order('name ASC')
+ #
+ # generates a query with 'ORDER BY id ASC, name ASC'.
+ #
def reorder(*args)
return self if args.blank?