【发布时间】:2021-07-24 04:17:43
【问题描述】:
我有一个用户模型,其中我有一个 default_scope 来获取所有仍处于活动状态的用户。除了默认范围外,我还命名了范围。我的用户模型看起来像:
default_scope { where(status: "active") }
范围 :location, -> (location) { where(location: location) }
对于特定查询,我需要绕过 default_scope 并使用位置范围。我知道我可以使用 unscoped 绕过范围,但根据我的理解,unscope 将绕过所有范围。
我该怎么做?
【问题讨论】:
标签: ruby-on-rails scopes