Why group calculation fields do not show up in query result?
问题 I have query like this: query = Link.select('url, max(created_at) as created_at, count(*) as url_count').group(:url).order('url_count desc, created_at asc') Sample results of query.results.first : 2.2.0 :002 > query.first => #<Link id: nil, url: "http://1", created_at: "2015-03-10 16:43:54"> Why there is no url_count here, even though I know it is. 2.2.0 :003 > query.first.url_count => 17 回答1: The count is there all along but the model to_s method does not know about it. The to_s method which