Sunday, March 27, 2011

Does anyone know any gems/plugins/tutorials related to exporting events to iCal, Google Calendar, Outlook from a Rails application?

I am trying to figure out if there is already a plug in that does the interaction with iCal, Google APIs that I can use or do I need to just get my hands dirty and write it myself.

If anyone knows of good resources that I can look at that could help me with the implementation, that would be good as well.

I am new to RoR and I have been trying to learn it for a while. I finally decided to just start playing with my own application rather than just following a book.

Any help in this matter would be appreciated.

Thanks!

From stackoverflow
  • Check out the Google Calendar gem for rails. It lets you display a user's Google Calendar in your rails app and they have sample snippets showing how to export events to Google Calendar:

    require 'googlecalendar'
    g = GData.new
    g.login('REPLACE_WITH_YOUR_MAIL@gmail.com', 'REPLACE_WITH_YOUR_PASSWORD')
    event = { :title=>'title',
    :content=>'content',
    :author=>'pub.cog',
    :email=>'pub.cog@gmail.com',
    :where=>'Toulouse,France',
    :startTime=>'2007-06-06T15:00:00.000Z',
    :endTime=>'2007-06-06T17:00:00.000Z'}
    g.new_event(event)
    

    For iCal, use the iCalendar gem and then you can export events as follows:

    require ‘icalendar’
    
    class EventController < ApplicationController
      def export_events
        @event = Event.find(params[:id])
        @calendar = Icalendar::Calendar.new
        event = Icalendar::Event.new
        event.start = @event.dt_time.strftime(”%Y%m%dT%H%M%S”)
        event.end = @event.dt_time.strftime(”%Y%m%dT%H%M%S”)
        event.summary = @event.summary
        event.description = @event.description
        event.location = @event.location
        @calendar.add event
        @calendar.publish
        headers['Content-Type'] = “text/calendar; charset=UTF-8″
        render_without_layout :text => @calendar.to_ical
      end
    end
    
  • Thanks Chris for the answer. I will give it a shot.

    Chris Bunch : Good luck! This link gives advice on how to get Outlook working with the iCalendar gem, but it seems a bit trickier: http://www.unfamiliarterritory.net/2008/06/using-icalendar-formatting-to-create-outlook-calendar-events-with-rails/
  • does this work in windows?

    tundal45 : Once you have the gem downloaded it should work in all platforms.
  • Hi,

    I have used the icalendar gem to export an event. I followed the code example above... it downloads the file, but its not an ical file.. hence the event does not show up on the outlook / ical calendar.. its just the text file that is downloaded which has the right contents. Am I missing sthing impt.. I need help to come out of this..

0 comments:

Post a Comment