Last Updated: February 25, 2016
·
602
· rafaelcgo

ActiveRecord - Retrieve only a column from DB

Use

.pluck(:column_name)

Example:

User.pluck(:email)
=> ["cliente1@fottorama.com.br", "cliente2@fottorama.com.br", "cliente3@fottorama.com.br"] 

http://apidock.com/rails/ActiveRecord/Calculations/pluck