{"comment":{"created_at":"2011-10-10T15:55:18Z","body":"What's it consistent with?\r\n\r\nMap yields each element to a block and returns an array of the results. Map with `&:attr` would call `attr` on all those records. But now map with `:attr` would return raw column values, having not iterated over the records at all, or called the `attr` method, which may be overridden.\r\n\r\nThis could make sense on the relation itself, but that's just `project`.","updated_at":"2011-10-10T15:55:18Z","url":"https://api.github.com/repos/rails/rails/issues/comments/2348833","id":2348833,"user":{"avatar_url":"https://secure.gravatar.com/avatar/24d2f8804e6bb4b7ea6bd11e0a586470?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jeremy","id":199,"login":"jeremy"}},"action":"created","issue":{"number":1915,"created_at":"2011-06-30T10:22:00Z","pull_request":{"diff_url":"https://github.com/rails/rails/pull/1915.diff","patch_url":"https://github.com/rails/rails/pull/1915.patch","html_url":"https://github.com/rails/rails/pull/1915"},"body":"In order to select single column from the ActiveRecord objects scope\r\nImplemented ActiveRecord::Base.map method that does direct query if\r\ncolumn name given or process as Array#map when block given.\r\n\r\n``` ruby\r\nPerson.map(:id) # SELECT people.id FROM people\r\nPerson.map(:role, :distinct => true) # SELECT DISTINCT role FROM people\r\nPerson.map(:id, :limit => 5, :conditions => {:confirmed => true})\r\n```\r\n\r\nMethod is also available in associtions:\r\n\r\n``` ruby\r\nproject.team_members.map(:role)\r\n```\r\n\r\nBackward compatibility - process as regular Array#map if block given:\r\n\r\n``` ruby\r\nPerson.limit(5).map(&:id)\r\nproject.team_members.map(&:role)\r\n```","comments":6,"title":"ActiveRecord::Base.map method for direct select by single column","updated_at":"2011-10-10T15:55:19Z","url":"https://api.github.com/repos/rails/rails/issues/1915","id":1143291,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/91913f6ab8085bab0f2aa43995ba8ca2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/bogdan","id":122436,"login":"bogdan"},"html_url":"https://github.com/rails/rails/issues/1915","labels":[],"state":"open"},"legacy":{"issue_id":1143291,"comment_id":2348833}}