Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
2.1.2 :008 > Employee.pluck(:age)
(0.4ms) SELECT "employees"."age" FROM "employees"
=> [19, 29, 20, 17, 25, 19, 27, nil]
2.1.2 :009 > Employee.pluck('age)
2.1.2 :010'> ^C
2.1.2 :010 > Employee.pluck(:age)
(0.4ms) SELECT "employees"."age" FROM "employees"
=> [19, 29, 20, 17, 25, 19, 27, nil]
2.1.2 :011 > Employee.pluck('age')
(0.7ms) SELECT "employees"."age" FROM "employees"
=> [19, 29, 20, 17, 25, 19, 27, nil]
2.1.2 :012 > Employee.select('age')
Employee Load (0.5ms) SELECT "employees"."age" FROM "employees"
=> #<ActiveRecord::Relation [#<Employee id: nil, age: 19>, #<Employee id: nil, age: 29>, #<Employee id: nil, age: 20>, #<Employee id: nil, age: 17>, #<Employee id: nil, age: 25>, #<Employee id: nil, age: 19>, #<Employee id: nil, age: 27>, #<Employee id: nil, age: nil>]>
2.1.2 :013 > Employee.select('age').pluck(:age)
(0.4ms) SELECT "employees"."age" FROM "employees"
=> [19, 29, 20, 17, 25, 19, 27, nil]
2.1.2 :014 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment