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)) 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -