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:
commit
a8d63c2fad
1 changed files with 6 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue