使用这个gem https://github.com/ankane/groupdate时,我在使用.count之外的任何东西时都会遇到问题
我有一些产品,我每隔几个小时将价格值存储在一个PriceHistory表中。以下查询正在运行(统计每天的price_histories数量)
Product.first.price_histories.group_by_day(:created_at, range: 7.days.ago..Time.now).count但这个不是(我正在尝试获得每天的最低价格)
Product.first.price_histories.group_by_day(:price, range: 7.days.ago..Time.now).minimum不管有没有宝石,我怎么做呢?
谢谢
发布于 2021-01-12 21:07:39
查询不正确,应该是正确的
Product.first.price_histories.group_by_day(:created_at, range: 7.days.ago..Time.now).minimum(:price)https://stackoverflow.com/questions/65680799
复制相似问题