@people = People.scoped
@people = @people.where(...) if ...
@people = @people.where(...) if ...
@people = @people.where(...) if ...
@people = @people.where(...) if ...
Is any ruby existing solutions to make something like
@people = People.scoped
@people.???? do
where(...) if ...
where(...) if ...
where(...) if ...
end
PS: Thanks for answers. But solutions you provide looks like
def self.conditional_scope
where(...) if ...
where(...) if ...
where(...) if ...
end
I think i'll get only last where even if all "if" is true.
Am i right?