Browse files

add documentation explaining reorder behavior

  • Loading branch information...
1 parent d7aff28 commit 23f8c635c0c8c9f6fbe810766104a4fa9f6794d4 @al2o3cr al2o3cr committed Jan 9, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 activerecord/lib/active_record/relation/query_methods.rb
View
10 activerecord/lib/active_record/relation/query_methods.rb
@@ -93,6 +93,16 @@ def order(*args)
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?

0 comments on commit 23f8c63

Please sign in to comment.