Permalink
Browse files

Add order docs

  • Loading branch information...
1 parent d7a2309 commit ad919087a4a816514a0a040ab9e2045e269a241f @oscardelben oscardelben committed Jul 6, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 activerecord/lib/active_record/relation/query_methods.rb
@@ -165,6 +165,16 @@ def group!(*args)
self
end
+ # Allows to specify an order attribute:
+ #
+ # User.order('name')
+ # => SELECT "users".* FROM "users" ORDER BY name
+ #
+ # User.order('name DESC')
+ # => SELECT "users".* FROM "users" ORDER BY name DESC
+ #
+ # User.order('name DESC, email')
+ # => SELECT "users".* FROM "users" ORDER BY name DESC, email
def order(*args)
args.blank? ? self : spawn.order!(*args)
end

0 comments on commit ad91908

Please sign in to comment.