Skip to content

Instantly share code, notes, and snippets.

@manlycode
Created December 12, 2017 20:33
Show Gist options
  • Save manlycode/0275c66c0ced7b79f85d32aba422b6fd to your computer and use it in GitHub Desktop.
Save manlycode/0275c66c0ced7b79f85d32aba422b6fd to your computer and use it in GitHub Desktop.
statement_join = customer
.statements
.joins("LEFT JOIN buildings_users ON buildings_users.building_id = statements.building_id")
.where(id: statements.map(&:id))
.where(buildings_users: { receive_reports: true })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment