1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #33360 from jedrekdomanski/Update-active-record-querying-readme

Update documentation for #pluck method [ci skip]
This commit is contained in:
Eileen M. Uchitelle 2018-07-14 13:38:13 -04:00 committed by GitHub
commit a8d63c2fad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1777,6 +1777,12 @@ Client.pluck(:name)
# => ["David", "Jeremy", "Jose"]
```
You are not limited to querying fields from a single table, you can query multiple tables as well.
```
Client.joins(:comments, :categories).pluck("clients.email, comments.title, categories.name")
```
Furthermore, unlike `select` and other `Relation` scopes, `pluck` triggers an immediate
query, and thus cannot be chained with any further scopes, although it can work with
scopes already constructed earlier: