aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/calculations.rb
diff options
context:
space:
mode:
authorwingfire <christof.spies@seips.net>2015-04-02 15:15:13 +0200
committerZachary Scott <e@zzak.io>2015-04-12 17:57:00 -0700
commita9f2c124aff3f61bd9dc2a023c37955652209f52 (patch)
tree4ff76970379b22823c84ebf343375f94b9c31824 /activerecord/lib/active_record/relation/calculations.rb
parenta05f3e5f96f7a8aa55483d91becdbe49b81833fd (diff)
downloadrails-a9f2c124aff3f61bd9dc2a023c37955652209f52.tar.gz
rails-a9f2c124aff3f61bd9dc2a023c37955652209f52.tar.bz2
rails-a9f2c124aff3f61bd9dc2a023c37955652209f52.zip
Enhance documentation of pluck with a hint to ids [ci skip]
Documentation is giving an example that can be replaced by a more dry command. Give a hint that ids can be used instead of pluck(:id).
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
-rw-r--r--activerecord/lib/active_record/relation/calculations.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index 8f16de3519..402b317d9c 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -130,9 +130,9 @@ module ActiveRecord
# the plucked column names, if they can be deduced. Plucking an SQL fragment
# returns String values by default.
#
- # Person.pluck(:id)
- # # SELECT people.id FROM people
- # # => [1, 2, 3]
+ # Person.pluck(:name)
+ # # SELECT people.name FROM people
+ # # => ['David', 'Jeremy', 'Jose']
#
# Person.pluck(:id, :name)
# # SELECT people.id, people.name FROM people
@@ -150,6 +150,8 @@ module ActiveRecord
# # SELECT DATEDIFF(updated_at, created_at) FROM people
# # => ['0', '27761', '173']
#
+ # See also +ids+.
+ #
def pluck(*column_names)
column_names.map! do |column_name|
if column_name.is_a?(Symbol) && attribute_alias?(column_name)