I'm sure this will be simple for someone who knows what they are doing. I want to write this statement as a scope - and I'd rather use Arel format but can't work out the OR inside the AND
select * from contacts where contact_type in (1,2) and
((contactable_type = 'Developer' and contactable_id = 10) or (contactable_type = 'Development' and contactable_id = 24))
so to start my scope - the first bit is simple
scope :of_type,
lambda { |types|
where(contact_type: types)
}
but it is the AND with nested ORs that I cannot get. I will obviously send in the ids I need
scope :of_type,
lambda { |types, developer_id, development_id |
where(contact_type: types) .. .
}