Created
March 30, 2017 20:32
-
-
Save cgibsonmm/0473c2372002756473528840c92228df to your computer and use it in GitHub Desktop.
Trying to return list of events on a calendar, but not getting any thing returned to the view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#event_controller.rb | |
class EventsController < ApplicationController | |
def index | |
@events = Event.all | |
@events_by_date = @events.group_by(&:date) | |
end | |
end | |
______________________________________________________ | |
# index.html.erb | |
<%= calendar do |date| %> | |
<%= date.day %> | |
<% if @events_by_date[date] %> | |
<ul> | |
<% @events_by_date[date].each do |event| %> | |
<li><%= event.title %></li> | |
<% end %> | |
</ul> | |
<% end %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment