sql - How to scope with "where", "having" and "or" -
i understand possible do
scope :public_visible, where("(status = ?) or (end_date > ?)", :published, date.today)
but want combining following 2 scopes or
scope :succeeded, having("sum(orders.sum) >= goal") scope :ongoing, where("end_date >= ?", date.today)
is possible? either in sql or activerecord ways.
thanks everyone.
not perfect solution ended doing
scope :succeeded_or_ongoing, where("id in (?) or id in (?)", project.succeeded.map(&:id), project.ongoing.map(&:id))