如何将 OR 逻辑与 name_scope 结合起来?
无论如何,是否可以组合多个named_scope,但将它们用作OR逻辑?
named_scope :a, { :conditions => ["posts.type_post == #{PERSONAL}"] }
named_scope :b, { :conditions => ["posts.type_post == #{PUBLIC}"] }
有没有办法使用这些 a 和 b 以便我得到 posts.type_post == PERSONAL
或 posts.type_post == PUBLIC
?
谢谢
Is there anyway to combine several named_scope but to use them as OR logic?
named_scope :a, { :conditions => ["posts.type_post == #{PERSONAL}"] }
named_scope :b, { :conditions => ["posts.type_post == #{PUBLIC}"] }
is there a way to use these a and b such that I get posts.type_post == PERSONAL
or posts.type_post == PUBLIC
?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要创建第三个范围,结合条件:
I think you will need to create a third scope, combining the conditions: