UPDATED 2008-11-19:
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.
Good luck!
Update 2008-11-25:
Found the text of the old tutorial.
Today we’ll go over an extremely simple way to add a javascript/css calendar to your Rails app. We will be using the Calendar Date Select Plugin. It is a small, easy to use calendar based on the prototype library.
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
Voila! Installed!
Now, we just need to integrate it.
First, in your layout you need to add the javascript tag:
<%= 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:
<%= javascript_include_tag :defaults %>
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.
I am using this plugin and got some problem when I start the server.
Exiting
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems.rb:578:in `report_activate_error’: RubyGem version error: hoe(1.7.0 not >= 1.8.0) (Gem::LoadError)
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems.rb:134:in `activate’
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems.rb:158:in `activate’
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems.rb:157:in `each’
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems.rb:157:in `activate’
It gives error when I add line inside environment.rb
config.gem “calendar_date_select”
please advice
Update your version of hoe, which is a gem creation tool:
e.g.
sudo gem install hoe
I am not able to format the date. If i follow your method the server is showing error
please Guide
I just found the website who reviews about
Several
home business ideas
If you want to know more here it is
home business reviews
http://www.home-businessreviews.com