Last active
May 19, 2016 12:46
-
-
Save rupurt/182a474bb9889b54fa50ec5bc0445014 to your computer and use it in GitHub Desktop.
includes AR weirdness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Should be 8 records | |
| ActiveRecord::Base.connection.execute(MembershipSummary.includes(:person).where(school_id: 2, group_id: 1).order("people.first_name asc NULLS LAST, person_id asc NULLS LAST").to_sql).count | |
| # Should be 8 records but only returns 1 | |
| MembershipSummary.includes(:person).where(school_id: 2, group_id: 1).order("people.first_name asc NULLS LAST, person_id asc NULLS LAST").to_a.size | |
| # 'joins' does what we want and returns 8 records. Maybe we can figure out how to get ransack to do a join instead of includes | |
| MembershipSummary.joins(:person).where(school_id: 2, group_id: 1).order("people.first_name asc NULLS LAST, person_id asc NULLS LAST").to_a.size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment