Skip to content

Commit

Permalink
add documentation explaining reorder behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
al2o3cr committed Jan 9, 2012
1 parent d7aff28 commit 23f8c63
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions activerecord/lib/active_record/relation/query_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down

0 comments on commit 23f8c63

Please sign in to comment.