我很困惑时间戳(created_at)和today
如何检索在特定日期创建的所有记录?
我想显示最近7天的报告,包括今天。
该报告显示每天发布的所有评论的数量。
如何修复下面的代码?什么来?????
<% user_ids = User.all %>
<% commentable = User.base_class.name.to_s %>
<% check_date = Date.today - 7 %>
<% 7.times do %>
<% @comments_count = Comment.where(:deleted_at => nil, :created_at => , ??????? :user_id => user_ids, :commentable_type => commentable).count %>
<%= @comments_count.to_s %> comments posted! on <%= check_date.to_s %> <br />
<% check_date = check_date + 1 %>
<% end %>
你能请定制我的原始代码,让我更深入了解?我想用我的代码去。 – HUSTEN
感谢您的多次尝试。我喜欢你的方式! – HUSTEN
谢谢,但你一定要尝试一下,看看哪个效果最好。 @Amit Thawait的代码比我的程序更清洁 –