This method is designed to perform select by a single column as direct SQL query Returns Array with values of the specified column name The values has same data type as column.
Person.pluck(:id) # SELECT people.id FROM people Person.uniq.pluck(:role) # SELECT DISTINCT role FROM people Person.where(:confirmed => true).limit(5).pluck(:id)
Its introduced rails 3.2 onwards and accepts only single column. In rails 4, it accepts multiple columns
~ Answered on 2012-10-11 16:30:27