Skip to content

Instantly share code, notes, and snippets.

@leemour
Created June 14, 2016 10:06
Show Gist options
  • Save leemour/eb0053fc51a8a6cd3187050aaf613513 to your computer and use it in GitHub Desktop.
Save leemour/eb0053fc51a8a6cd3187050aaf613513 to your computer and use it in GitHub Desktop.
Rails: HABTM - find all records with no association
Buyer.joins("left join buyers_metro_stations bms on buyers.id = bms.buyer_id").where("bms.id is null")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment