instance method
scoping
Ruby on Rails 3.1.12
Since v3.0.20Signature
scoping()
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.
Source
# File activerecord/lib/active_record/relation.rb, line 180
def scoping
@klass.send(:with_scope, self, :overwrite) { yield }
end
Defined in activerecord/lib/active_record/relation.rb line 180
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Relation