Using Enumerable, I am trying to display dates in an organized event calendar by dates. Not as a standard 7 grid calendar.
Trying to get:
December 1, 2011
Event 1
Event 2
Event 3
December 2, 2011
Event 4
Event 5
December 3, 2011
Event 6
…
Currently Enumerable confuses the hell outta me. Thanks for any guidance–
EDIT Dec.22,2011
Current Data:
Controller string-
@events = Event.where('start >= ?', Date.today).paginate(:per_page => 15, :page => params[:page])
View call-
<% @events.each do |event| %>
<table stuff here>
<% end %>
Method- Have not specified anything enumerable on method as of now—
My table includes the following fields; :title, :venue, :address (is geocoded), :about (text), :start (datetime function)
Update for question update: So you have a bunch of event objects in
@eventsso you could use agroup_by:That would give you a Hash in
@events_by_datewith dates as the keys and arrays of Event objects as the values.Then you’d want an array of arrays of Dates to match your month and drive the table from that array:
There would be some formatting involved of course but the structure would be similar.