Skip to content
Browse files

add documentation explaining reorder behavior

  • Loading branch information...
1 parent 96d4da1 commit d0915ac2f99e8e6db81dc4fb5cefe07d98f39fd0 @al2o3cr al2o3cr committed with vijaydev 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 d0915ac

Please sign in to comment.
Something went wrong with that request. Please try again.