aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_record_querying.textile
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-06-23 18:08:11 +0200
committerXavier Noria <fxn@hashref.com>2011-06-23 18:08:11 +0200
commit1f505a8ef21a300c22e4c6a3cc4d3bf4cf1853de (patch)
treee6d3457116b06dac44554b4100ff2ddfd13a64ee /railties/guides/source/active_record_querying.textile
parentd49622a1f211a036283dcd094c9da0da3bb39fa8 (diff)
parent06fe01a337ccf7f44bbaf272eddac284f80dcadb (diff)
downloadrails-1f505a8ef21a300c22e4c6a3cc4d3bf4cf1853de.tar.gz
rails-1f505a8ef21a300c22e4c6a3cc4d3bf4cf1853de.tar.bz2
rails-1f505a8ef21a300c22e4c6a3cc4d3bf4cf1853de.zip
Merge branch 'master' of git://github.com/lifo/docrails
Diffstat (limited to 'railties/guides/source/active_record_querying.textile')
-rw-r--r--railties/guides/source/active_record_querying.textile27
1 files changed, 27 insertions, 0 deletions
diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile
index b4ce60fcaa..e3871a3c34 100644
--- a/railties/guides/source/active_record_querying.textile
+++ b/railties/guides/source/active_record_querying.textile
@@ -57,6 +57,7 @@ The methods are:
* +group+
* +order+
* +reorder+
+* +reverse_order+
* +limit+
* +offset+
* +joins+
@@ -550,6 +551,32 @@ In case the +reorder+ clause is not used, the SQL executed would be:
SELECT * FROM posts WHERE id = 10 ORDER BY posted_at DESC
</sql>
+h4. +reverse_order+
+
+The +reverse_order+ method reverses the ordering clause if specified.
+
+<ruby>
+Client.where("orders_count > 10").order(:name).reverse_order
+</ruby>
+
+The SQL that would be executed:
+<sql>
+SELECT * FROM clients WHERE orders_count > 10 ORDER BY name DESC
+</sql>
+
+If no ordering clause is specified in the query, the +reverse_order+ orders by the primary key in reverse order.
+
+<ruby>
+Client.where("orders_count > 10").reverse_order
+</ruby>
+
+The SQL that would be executed:
+<sql>
+SELECT * FROM clients WHERE orders_count > 10 ORDER BY clients.id DESC
+</sql>
+
+This method accepts *no* arguments.
+
h3. Readonly Objects
Active Record provides +readonly+ method on a relation to explicitly disallow modification or deletion of any of the returned object. Any attempt to alter or destroy a readonly record will not succeed, raising an +ActiveRecord::ReadOnlyRecord+ exception.