eggie5 wrote:
> Hi,
>
> I have a collection of arbitrary objects that have a date attribute. I
> want to display these objects by month. For example
>
> @things=Thing.all
>
> Now I want to display in a table all the things by month - how can I
> do this? the problem isn't making a table or anything it's just the
> logic for getting the min and max range for all the dates in things
> and then finding the monthes to use for the scale and etc. Please give
> suggestions.
>
Well...
@things = @things.sort_by { |a, b| a.date <=> b.date }
That'll work to sort if the date attribute has the same name on all
objects.
>From there, you can also do "select" if a.date.month == 1, etc etc etc.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.