lundi 14 septembre 2015

Active Record query for object where at least one child has a certain attribute value

I have a rails app. That app has an institution model. Each institution has many users and many projects.

We recently added terms of service to the application and want to expose some project data for all institutions that have at least one user who has accepted the terms of service.

I am looking for an efficient query that accomplishes the following:

All projects for institutions with at least one user with accepted_terms == TRUE

Can you dig it?

Aucun commentaire:

Enregistrer un commentaire