What is the “rails way” to efficiently grab all rows of a parent table along with a count of the number of children each row has? I don’t want to use counter_cache as I want to run these counts based on some time conditions. The cliche blog example: Table of articles. Each article has 0 […]
Category: grouping
Getting single records back from joined tables that may produce multiple records
I’ve got a student table and an enrollment table; a student could have multiple enrollment records that can be active or inactive. I want to get a select that has a single student record and an indicator as to whether that student has active enrollments. I thought about doing this in an inline UDF that […]