仅按日期对created_at进行分组?

Rao*_*oot 7 activerecord ruby-on-rails-3

我的产品型号中有以下内容.

def grouped_created_at
  @created_ats = @products.group_by { |c| c.created_at }
end
Run Code Online (Sandbox Code Playgroud)

工作正常,但我想按日期分组.由于这是一个时间戳,我没有得到我需要的结果.任何人都可以建议如何修改这个?

非常感谢!

ros*_*sta 13

def grouped_created_at
  @created_ats = @products.group_by { |c| c.created_at.to_date }
end
Run Code Online (Sandbox Code Playgroud)