Skip to main content

← Back to the blog

SimpleCalendar 1.1 released!

This post was written by Chris Oliver on May 14, 2014.

Having spent a significant time over the years playing with various calendar gems, I felt they were all lacking in different ways. Some were overbearing providing you CSS stylesheets when all I wanted was a plain calendar. Others were a bit too involved, there was a lot of work on my end and all I wanted to do was render a simple table for the calendar.

Calendars also aren't necessarily a month anyways. Sometimes you want to see 6 weeks at a time. Sometimes 2 weeks. Sometimes you only want 4 days. But none of the gems seemed to care.

Seeing all this, I decided to make my own:

At the simplest version, simple_calendar renders a table for your calendar.

You can make a month calendar:

<%= month_calendar do |date| %>
<%= date %>
<% end %>

You can make a 2 week calendar:

<%= week_calendar number_of_weeks: 2 do |date| %>
<%= date %>
<% end %>

You can make a 4 day agenda calendar:

<%= calendar number_of_days: 4 do |date| %>
<%= date %>
<% end %>

The calendar just generates some basic HTML for you that you are free to work with, complete with navigation links and a header (if you want it).

  <a href="/events?start_date=2014-05-13">«</a>
  <a href="/events?start_date=2014-05-18">»</a>
<table class="table table-bordered">
      <td class="day today current-month wday-3" current="2014-05-14" start="2014-05-14">
      <td class="day future current-month wday-4" current="2014-05-15" start="2014-05-14">
      <td class="day future current-month wday-5" current="2014-05-16" start="2014-05-14">
      <td class="day future current-month wday-6" current="2014-05-17" start="2014-05-14">

These are fine and dandy, but what is a calendar without events? We've got that too.

Because we need to know what attribute on your model is the event's start time, we have a simple include in your model that lets you define it:

class Event < ActiveRecord::Base
extend SimpleCalendar
has_calendar attribute: :start_time

You define which attribute to use in your model and then simply pass them into your view to have them all sorted out by day.

<%= month_calendar events: Event.all do |date, events| %>
<%= date %>
<% events.each do |event %>
<div><%= %></div>
<% end %>
<% end %>

This will yield the date and all the events sorted by start time for the given date to your code. Do with them however you please, it is up to you.

I'm pleased with the end result currently and look forward to improving it more in the future. If you have any suggestions or improvements to make, make a Github issue and let's make the easiest calendar for Rails we can!

Try it out at

P.S. You might enjoy following me on Twitter.



Do you have a demo for this??


It just generates an HTML table, so there are no CSS styles applied by default. That's up to you. Here's a screenshot of it using Bootstrap. and an older version in use here at


Glad to have found simple_calendar. Thank you! Are there images missing or not displaying properly above? There are empty panels with captions above them saying things like, "You can make a 4 day agenda calendar:" I am trying to learn and understand all I can about simple_calendar in order to implement it in my app as soon as possible. Thank you again for your time and energy on this program.


Updated the post to show the code for those. I'll point you to the Github page for the latest info on the gem though:


Thank you so much!


Is it possible to display a weekly calendar with days going from Monday to Friday only? This is to make student timetable.


Yes, but you would want to create a custom class that inherits from the main calendar. You can take a look at this as an example and adapt it to be a business-week calendar.


I'm a newbie in Ruby and Rails as well, but I guess what you mean is to change this:

number_of_weeks = options.fetch(:number_of_weeks, 1) number_of_days = (number_of_weeks * 7) - 1

into this:

number_of_days = (number_of_weeks * 5) - 1

Is that it ??


Another option I just thought about is that you could use CSS to hide the weekends (the first and last TDs in each column) and render the normal week_calendar.


I will go for this one. Thanks

Login or create an account to join the conversation.