Mohammed Aslam about subscribe

Calendar using Ruby on Rails

When I was pretty new to Ruby and Rails, I had a requirement to implement a calendar showing month view in one of the pages. My initial thought was to make use of some plugin for this purpose. But I decided otherwise to write my own code for this.

You can download the source-code for the rails calendar from GitHub

You will just find two folders , controllers and views. Anyone with a running rails application can use ‘calendar controller’ and the ‘calendar views’ in their application. Once added the following files into our application, http://localhost:3000/calendar will take you to a page which will show the calendar for the present month. and you can navigate to various months. It is just a skeleton of calendar out there which can be styled and modified as per your requirements.

Some useful date functions , which can be used in this are:

date = Date.today #=> Tue, 26 Dec 2010
start_date = date.beginning_of_month #=> Wed, 01 Dec 2010
end_date = date.end_of_month # =>Fri, 31 Dec 2010

The code still looks very immature and needs improvement.

Related Posts

2 Comments

Leave a Reply

Latest Tweet

"Yaaaay . My Lenovo back to working condition. Thanks to Lenovo International warranty service :)"