---
title: Use where.missing for Rails 6.1+
impact: LOW
impactDescription: Use modern Rails APIs for finding records with missing associations.
tags: rails, active-record, simplicity, associations
---

## Use where.missing for Rails 6.1+

Use modern Rails APIs for finding records with missing associations. Use `where.missing(:association)` instead of left joins with null checks. This is more readable and expressive.

**Incorrect:**

```ruby
Post.left_outer_joins(:comments).where(comments: { id: nil })
```

**Correct:**

```ruby
Post.where.missing(:comments)
```

**Tools:** RuboCop (`Rails/WhereMissing`)
