SQLの場合:
select * from messages group by year(created_at), month(created_at);
Railsの場合:
Message.all.group_by { |m| m.created_at.beginning_of_month }
SQLの場合:
select * from messages group by year(created_at), month(created_at);
Railsの場合:
Message.all.group_by { |m| m.created_at.beginning_of_month }