I'm trying to gather and display some simple statistical data. I want
to display the number of Products created over the last month, grouped
by the day they were created. Am I on the right track as far as the
ActiveRecord finder and also how would I iterate over the results in
the view to spit out the date and the count of products for that day?
Thanks for any help.
# example sql that returns count and date, grouped by the date
SELECT count(*) as total, created_at as date FROM products GROUP BY
date(created_at) HAVING created_at >= '2009-07-31' and created_at <=
# AR finder?
@created_products = Product.find(:all, :group => "date
(created_at)", :having => ["created_at >= ?", 1.month.ago])
# view code?
<li>Date : Total</li>