Comment.where(:post_id=>1).scopingdoComment.first# SELECT * FROM comments WHERE post_id = 1end
Please check unscoped if you want to remove all previous scopes (including
the default_scope) during the execution of a block.
# File activerecord/lib/active_record/relation.rb, line 122
def scoping
@klass.scoped_methods << self
begin
yield
ensure
@klass.scoped_methods.pop
end
end