In my ruby on rails application, I wanted to get count of users that have been created and deleted account in the previous day, week and month in my app.Basically I want to show the users that have been created account in one day(means from current hour to previous remaining hours)
, one week(means from current day to previous remaining days)
and one month(means from current day to previous remaining days)
and I am trying use below:
# Controller
@users = User.all(:conditions => ["created_at >= ?", Date.today.at_beginning_of_month])
# View
Date.today.at_beginning_of_month.upto(Date.today).each do |date|
<%= date %>: <%= @users.select{|u| u.created_at == date }.size %>
end
But it gets me count of users for each day in past month.