1
我使用RoR 5.0.1和PostGres 9.5。我已经基于日期如何在Rails中编写“独特的”查找器方法?
select distinct on (crypto_currency_id) t.*
from crypto_prices t
order by crypto_currency_id, last_updated desc;
我的型号名称是CryptoPrice以下查询,从一个特定的表(由相应的模型来表示)得到重复的记录,但我不清楚如何转换上面的成取景器方法。这
CryptoPrice.distinct.pluck(:crypto_currency_id)
不会做同样的事情,因为我发现。