Cochon soutenant un autre question I posted, j'ai un complexe find()
qui change si un certain ID est nul ou non. Voir ici:Pouvez-vous me parler d'une gemme ruby décent que je peux utiliser pour des jointures complexes?
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
Je me demande s'il y a un petit bijou là-bas qui me permet de passer en: premier: conditions de choses type que un bloc de code. J'ai vu ez_where sur github mais je ne savais pas si elle avait été abandonnée ou non puisqu'elle n'avait pas d'activité dernièrement (bien que cela puisse signifier qu'elle soit très solide sans aucun bogue) Des idées?
Oui, c'est exactement ce que je cherche. J'utilise 2.3.5 en ce moment, donc si cela a été intégré dans les rails 3, cela m'aidera dans la transition, merci! – DJTripleThreat