I have a collection of of objects from an query. I can group them by using:
@dogs.group_by(&:birth_date)
that works fine... and it groups them by date, however, I want to group them by month. How can I do this?
I have a collection of of objects from an query. I can group them by using:
@dogs.group_by(&:birth_date)
that works fine... and it groups them by date, however, I want to group them by month. How can I do this?
or group by week for that matter...
If :birth_date is a Date, for instance, you could do it like this:
@dogs.group_by{|dog| dog.birth_date.month}
thanks