diff options
author | Oscar Del Ben <oscar@oscardelben.com> | 2012-07-05 19:02:58 -0700 |
---|---|---|
committer | Oscar Del Ben <oscar@oscardelben.com> | 2012-07-05 19:02:58 -0700 |
commit | ad919087a4a816514a0a040ab9e2045e269a241f (patch) | |
tree | 95909ba24c428c204990a9f57a662a6063406c6b /activerecord | |
parent | d7a2309fe39d3807c1c97de116b23d6bb2c08d79 (diff) | |
download | rails-ad919087a4a816514a0a040ab9e2045e269a241f.tar.gz rails-ad919087a4a816514a0a040ab9e2045e269a241f.tar.bz2 rails-ad919087a4a816514a0a040ab9e2045e269a241f.zip |
Add order docs
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 10 |
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 1636e49065..94843dd2c6 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -165,6 +165,16 @@ module ActiveRecord 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 |