Ask A Question

Notifications

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

Hey,

You can set `sorted = Hash.new([])` in `sorted_events` so that you don't have to be defensive in the view.

Reply

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?

Reply

Sure! Send it my way!

Reply

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?

Reply

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

Reply
Join the discussion
Create an account Log in

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

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

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

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.