Skip to content

Commit f7e4362

Browse files
committed
[ci skip] Doc ability to chain in find_each
Also use appropriate mailer syntax in the `find_each` block.
1 parent 63f4155 commit f7e4362

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

guides/source/active_record_querying.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,15 @@ The `find_each` method retrieves a batch of records and then yields _each_ recor
309309

310310
```ruby
311311
User.find_each do |user|
312-
NewsLetter.weekly_deliver(user)
312+
NewsMailer.weekly(user).deliver
313+
end
314+
```
315+
316+
To add conditions to a `find_each` operation you can chain other Active Record methods such as `where`:
317+
318+
```ruby
319+
User.where(weekly_subscriber: true).find_each do |user|
320+
NewsMailer.weekly(user).deliver
313321
end
314322
```
315323

0 commit comments

Comments
 (0)