在我的模特中,我有:
start = 3.weeks.ago
kliks = where(created_at: start.beginning_of_day..Time.zone.now)
kliks = kliks.group("date(created_at)")
如何计算每天的所有记录总数?
答案 0 :(得分:10)
我相信这应该有效:
kliks = count(
:group => 'date(created_at)',
:conditions => { :created_at => start.beginning_of_day..Time.zone.now }
)
这会将哈希映射日期返回给他们的计数。