Piggy backing off another question I posted, I have a complex find()
that changes whether or not a certain id is nil or not. See here:
if self.id.nil?
blocks = AppointmentBlock.find(:first,
:conditions => ['appointment_blocks.employee_id = ? and ' +
'(time_slots.start_at between ? and ? or time_slots.end_at between ? and ?)',
self.employee_id, self.time_slot.start_at, self.time_slot.end_at,
self.time_slot.start_at, self.time_slot.end_at],
:joins => 'join time_slots on time_slots.time_slot_role_id = appointment_blocks.id')
else
blocks = AppointmentBlock.find(:first,
:conditions => ['appointment_blocks.id != ? and ' +
'appointment_blocks.employee_id = ? and ' +
'(time_slots.start_at between ? and ? or time_slots.end_at between ? and ?)',
self.id, self.employee_id, self.time_slot.start_at, self.time_slot.end_at,
self.time_slot.start_at, self.time_slot.end_at],
:joins => 'join time_slots on time_slots.time_slot_role_id = appointment_blocks.id')
end
I'm wondering if there is a gem out there that lets me pass in :first and :conditions type stuff as a block of code. I saw ez_where on github but wasn't sure if it was abandoned or not since its had no activity lately (although that could mean its very solid with no bugs) Any ideas?