iCal ( iCalendar ) Publishing to *.ics file through RubyOnRails
December 10, 2007
To publish iCal through Rails, install iCalendar gem
gem install icalendar
then in Controller, code to export event ( export to *.ics file ) should look like,
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
March 4, 2008 at 12:46 pm
[...] iCal (iCalendar) Publishing to *.ics file through RubyOnRails [...]