是否有组合几个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
?
谢谢
答案 0 :(得分:0)
我认为你需要创建第三个范围,结合条件:
named_scope :a_or_b, { :conditions => ["posts.type_post in (#{PUBLIC}, #{PERSONAL})"] }