Ask A Question


You’re not receiving notifications from this thread.

Open Source Vlog - Sorting Calendar Events | GoRails - GoRails

Chris Oliver asked in General
Dwayne Crooks Dwayne Crooks


You can set `sorted =[])` 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?


Sure! Send it my way!


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 %>

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,168+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.