Skip to content

Commit a8d63c2

Browse files
authored
Merge pull request rails#33360 from jedrekdomanski/Update-active-record-querying-readme
Update documentation for #pluck method [ci skip]
2 parents bd5eba1 + 1e2650a commit a8d63c2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

guides/source/active_record_querying.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,12 @@ Client.pluck(:name)
17771777
# => ["David", "Jeremy", "Jose"]
17781778
```
17791779

1780+
You are not limited to querying fields from a single table, you can query multiple tables as well.
1781+
1782+
```
1783+
Client.joins(:comments, :categories).pluck("clients.email, comments.title, categories.name")
1784+
```
1785+
17801786
Furthermore, unlike `select` and other `Relation` scopes, `pluck` triggers an immediate
17811787
query, and thus cannot be chained with any further scopes, although it can work with
17821788
scopes already constructed earlier:

0 commit comments

Comments
 (0)