Use #pluck as a shortcut to select one or more attributes without loading a bunch of records just to grab the attributes you want.

instead of

Person . all . map (& :name )

Pluck returns an Array of attribute values type-casted to match the plucked column names, if they can be deduced. Plucking an SQL fragment returns String values by default.

Person . pluck ( :name ) Person . pluck ( :id , :name ) Person . distinct . pluck ( :role ) Person . where ( age : 21 ). limit ( 5 ). pluck ( :id ) Person . pluck (' DATEDIFF(updated_at, created_at) ')

See also #ids.