aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2014-06-28 14:46:33 -0500
committerschneems <richard.schneeman@gmail.com>2014-06-28 17:49:40 -0500
commitf7e4362011ceb1317fd401125d48d7ccb9a1079c (patch)
treec75ca9e0c6058c9c38372aea4f8da244cb810137 /guides/source
parent63f4155596d1403dbf4972adc0d5877c1ea6d2b0 (diff)
downloadrails-f7e4362011ceb1317fd401125d48d7ccb9a1079c.tar.gz
rails-f7e4362011ceb1317fd401125d48d7ccb9a1079c.tar.bz2
rails-f7e4362011ceb1317fd401125d48d7ccb9a1079c.zip
[ci skip] Doc ability to chain in `find_each`
Also use appropriate mailer syntax in the `find_each` block.
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/active_record_querying.md10
1 files changed, 9 insertions, 1 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 0b6f40c129..311df3a953 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -309,7 +309,15 @@ The `find_each` method retrieves a batch of records and then yields _each_ recor
```ruby
User.find_each do |user|
- NewsLetter.weekly_deliver(user)
+ NewsMailer.weekly(user).deliver
+end
+```
+
+To add conditions to a `find_each` operation you can chain other Active Record methods such as `where`:
+
+```ruby
+User.where(weekly_subscriber: true).find_each do |user|
+ NewsMailer.weekly(user).deliver
end
```