Bah, found it here: https://stackoverflow.com/a/5570221/417872
City.includes(:photos).where(photos: { city_id: nil })
More Related Contents:
- ActiveRecord Arel OR condition
- Join multiple tables with active records
- PostgreSQL where all in array
- Rails 4 LIKE query – ActiveRecord adds quotes
- Find all records which have a count of an association greater than zero
- ActiveRecord find_each combined with limit and order
- Rails raw SQL example
- How to use ANY instead of IN in a WHERE clause?
- PostgreSQL GROUP BY different from MySQL?
- MySQL not using indexes with WHERE IN clause?
- Best way to count rows by arbitrary time intervals
- Disable Rails SQL logging in console
- LEFT OUTER JOIN in Rails 4
- Rails 3 execute custom sql query without a model
- Perform this hours of operation query in PostgreSQL
- SQL where joined set must contain all values but may contain more
- Find records where join doesn’t exist
- Prepared Statement on Postgresql in Rails
- Insert into … values ( SELECT … FROM … )
- How to create id with AUTO_INCREMENT on Oracle?
- Difference between EXISTS and IN in SQL?
- How should I pass a table name into a stored proc?
- What’s the difference between DoCmd.SetWarnings and CurrentDB.Execute
- SQL Join Differences
- Get the last inserted row ID (with SQL statement) [duplicate]
- Get the week start date and week end date from week number
- Sql Server deterministic user-defined function
- How to get the numeric part from a string using T-SQL?
- How to renumber primary index
- SQL query to select distinct row with minimum value