Permalink
Browse files

Fix events not showing on calendar due to date type formats

  • Loading branch information...
carolinagc committed Dec 12, 2013
1 parent 3194ee8 commit 32f91ae2e38aa6f789133a3856530c27a7e06bc4
@@ -0,0 +1,3 @@
jQuery ->
$('#event_day').datetimepicker(dateFormat: "DD, d MM, yy", timeFormat: "h:mm TT")

@@ -0,0 +1,46 @@
#events .calendar {
border-collapse: collapse;
width: 100%;

td, th {
font-family: "Lucida Grande", arial, helvetica, sans-serif;
font-size: 10px;
padding: 6px;
border: 1px solid #999;
}

th {
background: #DDD;
color: #666;
text-align: center;
width: 14.2857142857143%;
}

td {
background: #FFF;
color: #777;
height: 80px;
vertical-align: top;
font-size: 16px;
}

.notmonth, .notmonth a { color: #CCC; }
.today { background-color: #D7F2FF; }
}

#events #month {
margin: 0;
padding-bottom: 10px;
text-align: center;
font-size: 22px;
a {
text-decoration: none;
padding: 0 10px;
color: #999;
}
}

#events ul {
font-size: 11px;
padding-left: 20px;
}
@@ -5,11 +5,11 @@ def index

def calendar
@events = Event.all
@events_by_date = @events.group_by(&:day)
@date = params[:date] ? Datetime.parse(params[:date]) : Date.today


end
# @events_by_date = @events.group_by(&:day)
@events_by_date = @events.group_by { |i| i.day.strftime("%Y %m %d") }
@date = params[:date] ? DateTime.parse(params[:date]) : Date.today
end

def show
@event = Event.find(params[:id])
@@ -1,6 +1,17 @@
<div id="events">
<h2 id="month">
<%= link_to "<", date: @date.prev_month %>
<%= @date.strftime("%B %Y") %>
<%= link_to ">", date: @date.next_month %>
</h2>
<%= calendar @date do |date| %>
<%= date.day %>

<% if @events_by_date[date.strftime("%Y %m %d")] %>
x <ul>
<% @events_by_date[date.strftime("%Y %m %d")].each do |event| %>
<li><%= link_to event.name, event %></li>
<% end %>
</ul>
<% end %>
<% end %>
</div>

0 comments on commit 32f91ae

Please sign in to comment.