Skip to content

Instantly share code, notes, and snippets.

@ceneon
ceneon / Rails test
Created February 25, 2011 15:46
A complex ActiveRecord find through a lot of models.. I think there must be a better way to do it
@operadores = User.find(:all, :conditions =>
{ :id =>
EventoTrabajosUser.find(:all, :conditions =>
{ :evento_trabajo_id =>
EventoTrabajo.find(:all, :conditions =>
{ :evento_id => @planificacion.eventos.collect{ |b| b.id } }
).collect { |c| c.id }
}).collect { |d| d.user_id }
})