Rails Scopes reference
25 April 2022 (Updated 25 April 2022)
What are Scopes?
Scopes let you define commonly used queries as methods on models. Scopes should return ActiveRecord::Relation
or nil
to allow other methods and scopes to be chained.
Define scope using lambda
Call it:
Define scope that takes arguments
Define default scope
Remove scope
Sources
Tagged:
Rails
Thanks for your comment . Once it's approved, it will appear here.
Leave a comment