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)
不會做同樣的事情,因爲我發現。