I have the following scope in Rails.
scope :with_active_services, Contact.joins(:i_services, :c_services).merge(IService.enabled).merge(CService.enabled)
What I'm trying to achieve is selecting a contact which has either enabled i_services or c_services. Contacts don't necessary have both.
I've run into a few problems which I cannot get my head around.
The way the scope is at the moment will mean a contact will need to have both an enabled i_service and c_service to be returned.
When I take the SQL generated and change the AND in the WHERE condition to OR I run into the problem that a contact still needs to have both a c_service and i_service to be returned.
How can I modify this to meet my requirements?
Thanks.