Skip to content

Instantly share code, notes, and snippets.

@ceneon
Created February 25, 2011 15:46
Show Gist options
  • Save ceneon/843970 to your computer and use it in GitHub Desktop.
Save ceneon/843970 to your computer and use it in GitHub Desktop.
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 }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment