I know that Person.find(:all) returns an array of Person objects but is there somehow I can just get 'name' property of all people in the Person table?
Something like
Person.find(:all).names
Use :select to retrieve only specific attributes.
Person.all(:select => :name)
Would give you person objects that only have the name attribute initialized. Then you can map/collect that attribute to get the array of names.
Person.all.collect(&:name)& for &:name?Person.all.collect { |p| p.name } or the following three-liner: Person.all.collect do |p| p.name end This is a good explanation: stackoverflow.com/a/9468624/444681