method
scoping
v3.0.0 -
Show latest stable
- Class:
ActiveRecord::Relation
scoping()public
Scope all queries to the current scope.
Example
Comment.where(:post_id => 1).scoping do Comment.first # SELECT * FROM comments WHERE post_id = 1 end
Please check unscoped if you want to remove all previous scopes (including the default_scope) during the execution of a block.