March 2008

On one of our platforms that uses the geocoding services from the google maps api v2 (using client side javascript) we fell upon a very very weird bug.

For the same city google gives different answers based upon the presence of accents in the query string.

1. When you look for Angoulême (the correct spelling, see the small hat upon the e? called accent circonflexe or by it's html entity name ê) Google's geocoding api gives the incorrect answer of angouleme without the accent.

ICalendar is a standard (RFC 2445) for calendar data exchange. The standard is sometimes referred to as "iCal", which also is the name of the Apple, Inc. calendar program that provides one of the implementations of the standard. Source: ICalendar.

It's possible to generate ICalendar files with Ruby on Rails. This can be useful for letting users adding your events in their calendars.

The first step is the install of the icalendar gem: gem install icalendar. An alternative can be vpim.

Then, this library must be required from rails. Add require 'icalendar' to your config/environment.rb file. You can require it from elsewhre, but I think that config/environment.rb is a good place.

Here, we are ready to code our export of events fo .ics file. We suppose that we have an Events model:

  1. class Event < ActiveRecord::Base
  2. # Table name: events
  3. #
  4. #  id           :integer(11)     not null, primary key
  5. #  title        :string(255)
  6. #  date         :datetime
  7. #  end_date     :datetime
  8. #  summary      :text
  9. #  content      :text
  10. #  created_at   :datetime
  11. #  updated_at   :datetime
  12. end

We add a to_ics to this class:

  1. # Convert to iCalendar
  2. def to_ics
  3. event = Icalendar::Event.new