How to combine OR logic with named_scope?

323 views Asked by At

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

1

There are 1 answers

1
Jeff Paquette On

I think you will need to create a third scope, combining the conditions:

named_scope :a_or_b, { :conditions => ["posts.type_post in (#{PUBLIC}, #{PERSONAL})"] }