From 1e2650acbb1178da7d24bb9cdac31920c2f75dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drek=20Doma=C5=84ski?= Date: Sat, 14 Jul 2018 14:11:30 +0200 Subject: [PATCH] Update documentation for #pluck method [ci skip] --- guides/source/active_record_querying.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 944cee8a23..6c57cd8b8e 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -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: