File: //usr/local/rvm/gems/default/doc/activerecord-6.1.4.1/ri/ActiveRecord/Calculations/pluck-i.ri
U:RDoc::AnyMethod[iI"
pluck:ETI"%ActiveRecord::Calculations#pluck;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"GUse #pluck as a shortcut to select one or more attributes without ;TI"Eloading a bunch of records just to grab the attributes you want.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"Person.pluck(:name)
;T:@format0o;
; [I"instead of;T@o;; [I"Person.all.map(&:name)
;T;
0o;
; [I"EPluck returns an Array of attribute values type-casted to match ;TI"Pthe plucked column names, if they can be deduced. Plucking an SQL fragment ;TI"&returns String values by default.;T@o;; [I"Person.pluck(:name)
;TI"&# SELECT people.name FROM people
;TI"&# => ['David', 'Jeremy', 'Jose']
;TI"
;TI"Person.pluck(:id, :name)
;TI"1# SELECT people.id, people.name FROM people
;TI"5# => [[1, 'David'], [2, 'Jeremy'], [3, 'Jose']]
;TI"
;TI""Person.distinct.pluck(:role)
;TI"(# SELECT DISTINCT role FROM people
;TI"'# => ['admin', 'member', 'guest']
;TI"
;TI"/Person.where(age: 21).limit(5).pluck(:id)
;TI"B# SELECT people.id FROM people WHERE people.age = 21 LIMIT 5
;TI"# => [2, 3]
;TI"
;TI"@Person.pluck(Arel.sql('DATEDIFF(updated_at, created_at)'))
;TI";# SELECT DATEDIFF(updated_at, created_at) FROM people
;TI" # => ['0', '27761', '173']
;T;
0o;
; [I"See also #ids.;T:
@fileI"/lib/active_record/relation/calculations.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(*column_names);T@6FI"Calculations;TcRDoc::NormalModule00