查看導軌的Google Calendar gem。它可以讓你在你的Rails應用程序顯示用戶的谷歌日曆和他們的示例代碼段顯示瞭如何事件導出到谷歌日曆:
require 'googlecalendar'
g = GData.new
g.login('[email protected]', 'REPLACE_WITH_YOUR_PASSWORD')
event = { :title=>'title',
:content=>'content',
:author=>'pub.cog',
:email=>'[email protected]',
:where=>'Toulouse,France',
:startTime=>'2007-06-06T15:00:00.000Z',
:endTime=>'2007-06-06T17:00:00.000Z'}
g.new_event(event)
對於iCal中,使用iCalendar gem,然後你可以如下導出事件:
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
嘿謝謝你的回答,任何想法如何導出到Outlook? – jpemberthy 2012-04-02 16:18:10