Skip to content

Latest commit

 

History

History
14 lines (11 loc) · 398 Bytes

select-vs-pluck.md

File metadata and controls

14 lines (11 loc) · 398 Bytes

select vs pluck

A good way of limiting queries in ActiveRecord is with select or pluck, but they have different return values:

> Book.all.select(:title)
# => [#<Book:0x000000055cf0f8 id: nil, title: "The Great Gatsby">]
> Book.all.pluck(:title)
# => ["The Great Gatsby"]

Consider using pluck in hotter paths.