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

StackOverflow https://stackoverflow.com/questions/493300

Question

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!

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top