Skip to content

Commit

Permalink
Merge pull request #34534 from gmcgibbon/ar_query_scope_body_doc
Browse files Browse the repository at this point in the history
Clarify scope body requirements
  • Loading branch information
rafaelfranca committed Nov 28, 2018
2 parents 00638f3 + 7e4eeca commit a01e0d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion guides/source/active_record_querying.md
Expand Up @@ -1267,7 +1267,7 @@ This is because it is ambiguous whether they should appear on the parent record,
Scopes
------

Scoping allows you to specify commonly-used queries which can be referenced as method calls on the association objects or models. With these scopes, you can use every method previously covered such as `where`, `joins` and `includes`. All scope methods will return an `ActiveRecord::Relation` object which will allow for further methods (such as other scopes) to be called on it.
Scoping allows you to specify commonly-used queries which can be referenced as method calls on the association objects or models. With these scopes, you can use every method previously covered such as `where`, `joins` and `includes`. All scope bodies should return an `ActiveRecord::Relation` or `nil` to allow for further methods (such as other scopes) to be called on it.

To define a simple scope, we use the `scope` method inside the class, passing the query that we'd like to run when this scope is called:

Expand Down

0 comments on commit a01e0d0

Please sign in to comment.