$ gem install icalendar
requre 'icalendar'

calendar = Icalendar::Calendar.new                                                                                 
event = Icalendar::Event.new                                                                                       
event.start = Date.new(2013, 7, 1)
event.end = Date.new(2013, 7, 8)
event.summary = "Foo Festival"
event.description = "Greatest event in the world."
event.location = "Hatsudai Tokyo Japan"
calendar.add_event(event)

puts calendar.to_ical

railsでリンクをクリックしたらiCalファイルダウンロード → iCal起動+登録ってやりたい場合。

class FooController < ApplicationController
  def calendar
    calendar = Icalendar::Calendar.new

    # implementation...

    headers['Content-Type'] = 'text/calendar; charset=UTF-8'
    render :inline, layout: false, text: calendar.to_ical
  end
end

Comments


(Option)