diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-07-27 18:08:18 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-07-27 18:08:18 +0100 |
commit | 3205c768b7c592e5b96fdf6a6dd0fd3c2c9e5775 (patch) | |
tree | 631aebab77a934df61ecfef4c9aaea3d69825eeb /guides | |
parent | d1099540aff6cf00f31dafbbceed1f9fc48780a2 (diff) | |
download | rails-3205c768b7c592e5b96fdf6a6dd0fd3c2c9e5775.tar.gz rails-3205c768b7c592e5b96fdf6a6dd0fd3c2c9e5775.tar.bz2 rails-3205c768b7c592e5b96fdf6a6dd0fd3c2c9e5775.zip |
Changelog and doc updates for the previous changes.
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/active_record_querying.textile | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/guides/source/active_record_querying.textile b/guides/source/active_record_querying.textile index f71a136b22..b13932e8cb 100644 --- a/guides/source/active_record_querying.textile +++ b/guides/source/active_record_querying.textile @@ -1132,21 +1132,6 @@ Using a class method is the preferred way to accept arguments for scopes. These category.posts.created_before(time) </ruby> -h4. Working with scopes - -Where a relational object is required, the +scoped+ method may come in handy. This will return an +ActiveRecord::Relation+ object which can have further scoping applied to it afterwards. A place where this may come in handy is on associations - -<ruby> -client = Client.find_by_first_name("Ryan") -orders = client.orders.scoped -</ruby> - -With this new +orders+ object, we are able to ascertain that this object can have more scopes applied to it. For instance, if we wanted to return orders only in the last 30 days at a later point. - -<ruby> -orders.where("created_at > ?", 30.days.ago) -</ruby> - h4. Applying a default scope If we wish for a scope to be applied across all queries to the model we can use the +default_scope+ method within the model itself. |