aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--guides/source/active_record_querying.textile10
1 files changed, 10 insertions, 0 deletions
diff --git a/guides/source/active_record_querying.textile b/guides/source/active_record_querying.textile
index e211466339..671253709a 100644
--- a/guides/source/active_record_querying.textile
+++ b/guides/source/active_record_querying.textile
@@ -1158,6 +1158,16 @@ When queries are executed on this model, the SQL query will now look something l
SELECT * FROM clients WHERE removed_at IS NULL
</sql>
+If you need to do more complex things with a default scope, you can alternatively define it as a class method:
+
+<ruby>
+class Client < ActiveRecord::Base
+ def self.default_scope
+ # Should return a scope
+ end
+end
+</ruby>
+
h4. Removing all scoping
If we wish to remove scoping for any reason we can use the +unscoped+ method. This is especially useful if a +default_scope+ is specified in the model and should not be applied for this particular query.