Rails Calendar

 

Rails Calendar on a HTML Table

 For my recent rails project, I decided that I wanted to somehow figure out a way to make myself a personalized dashboard page.  I was in need of a notebook type organizer that would serve me for keeping notes and allowing me to have a calendar view of the current month from the homepage.  Here is how I approached a html calendar.


Establishing the Parameters of a Calendar Month

When I generate my calendar I am going to set up the date range using rail's built in time methods.  There are many useful method included in rails, below I am using the #.beginning_of_month and the #.end_of_month methods to grab the calendar data on either side of my start date and then put that span of dates into a #date_range array. 

 Making a HTML Table Calendar

 Once we have our #date_range array and #start_date methods set up, we can begin to split and translate the array into something that we'll begin to recognize as a calendar.

A few notes about the code below:

I have used this as a partial in my rails project to render an overall view of the current month and give a bird's eye view the current month.  Here is the final result with a little CSS.


 

Comments