Open Source Vlog - Sorting Calendar Events | GoRails - GoRails
Hey,
You can set `sorted = Hash.new([])` in `sorted_events` so that you don't have to be defensive in the view.
Hey Chris! I've been using this gem to get a better feel for it and came across a question. I posted on stackoverflow and was wondering if you could give it a look?
Hey Chris! Is there a way I can display color coded events based on an event_type? Say in this example I could have "work_meetings" or "personal_meetings" and one would be blue and the other one yellow. Is there a way to achieve this?
Absolutely! You can just pass in an array with all the meetings and then inside the block you can print them out differently using a helper or something. Rough outline here, first section goes in the controller.
# Pass @meetings into the calendar
@meetings = work_meetings + personal_meetings
<% month_calendar meetings: @meetings do |day, meetings| %>
<% meetings.each do |meeting| %>
<% if meeting.meeting_type == "work_meeting" %>
Code for work meeting
<% else %>
Code for personal meeting
<% end %>
<% end %>
<% end %>