[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PhillyOnRails] How can I group objects with a datetime field just by date, ignoring time?
|
Perfect! Thanks. I was on that track, but I was trying to format the
date, which only gave me a string and didn't compile (I think that was
my problem). I didn't think of creating/getting the date object
without the time.
On Nov 19, 2007, at 11:45 AM, Mike Mangino wrote:
Group by takes a block, so you can do
days = location.meetings.group_by {|meeting|
meeting.start_date.to_date}
You can then sort each result by the start_date.
Mike
On Nov 19, 2007, at 9:06 AM, Jared Blitzstein wrote:
I'm just getting back into Ruby/RoR so I'm pretty rusty on
everything (and I don't know Ruby that well to boot). The problem
I'm having is I have two classes, Location and Meeting with a 1:M
relationship. My Meeting class has start_date:datetime and
duration:integer (which is the number of minutes). I want to
display this data in a table with the time (7:00am, 8:00am...etc)
as the X axis on top and the Location as the Y axis on the left
(example: http://jared.blitzstein.net/assets/2007/11/19/matrix_1.html)
. I was looking at the Enumerable group_by ( http://api.rubyonrails.org/classes/Enumerable.html#M001111)
but it takes the time into account when I group it by start_time,
I want it to just use the date. Any suggestions how to display my
data?
I'm not opposed to changing my field types either, by doing
something like start_time/end_time, or start_date/start_time/
end_date/end_time etc.
_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk
--
Mike Mangino
http://www.elevatedrails.com
_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk
_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk
|
|