当我跑步时
sql = "select count( school_id ) as vote_total,
row_number() over( order by count( school_id )
DESC ) as rank, school_id
from votes
where school_id = 111111
group by school_id"
在 phpPgAdmin 中,我得到了我正在寻找的东西
vote_total rank school_id
68 1 111111
但是当我对 Vote.find_by_sql 做同样的事情时,我得到了
[#<Vote id: nil, school_id: 111111>]
我猜 find_by_sql 不是我应该使用的。关于正确方法的任何想法?