This is by far my most viewed blog post. Honestly, these days, I just use jquery-ui and the datepicker widget.
I didn’t update my blog for over a year, and as such decided to perform a reboot. The information previously contained on this page was out of date, and as such I didn’t keep it around. However, it turns out there’s a few places linking to this page, so I’ve decided to at least keep this from 404′ing.
The original blog post was centered around a plugin that you can now find at: http://code.google.com/p/calendardateselect
It really is a great plugin, and if you go to the site you’ll find it’s got very simple instructions on how to install and use it.
Found the text of the old tutorial.
This was written back in the day for Rails 1.2, so take all this information with a grain of salt.
Installation is simple, and uses the typical installation syntax:
script/plugin install http://calendardateselect.googlecode.com/svn/tags/calendar_date_select
Now, we just need to integrate it.
<%= calendar_date_select_includes “silver” %>
You can also use “red”, “blue” or “nil” for other color schemes.
Also note that you need to have prototype included as well, so if you haven’t already, you should also add the following to your layout:
And now, we’re ready to use it! Usage is simple. I was using it to keep track of an expiry date for a property, so I used to the following tag:
<%= calendar_date_select_tag “property[expiry_date]“, @property.expiry_date.to_s %>
If you wish, you can also check out the demo section for more information on using it with Form Builder.
Finally, I didn’t like the default ‘natural’ syntax for the date “August 8th, 2007″, so I changed it to use my preference, hyphenated syntax. To do this, open your environment.rb file and add the following line:
CalendarDateSelect.format = :hyphen_ampm
There! That is all I needed to do. Of course, there are more options, simply adding a :time => true will allow you to have a time field as well. There are a few more configuration options available for the calendar. You can find out more and get some more screenshots by visiting the project’s homepage.