dimanche 5 juin 2016

How to use joins inside includes in rails active record query?

I am just trying to improve query, so that it result's in improving permofance fo application.

 Student.includes(:parents =>:emails).where("emails.email_address is not null and emails.email_address != ''")

I just wanted to meet conditions using emails table, so clearly it is not required to eagerload emails table, instead i would prefer joins. But I am not able to figure out, how to use includes and joins together?. So that it should eagerload parents and joins with emails

Aucun commentaire:

Enregistrer un commentaire