开发者

How Do I create an .ics file with rails and ri_cal?

I am using rails 3 and the ri_cal gem. I am not able to produce a valid .ics file. It gets generated, but AppleCalendar or GoogleCalendar say it's empty. What did I do wrong? Help appreciated, thanks in advance :)

My Controller

class WebsitesController < ApplicationControll开发者_开发知识库er
  def index

    respond_to do |format|

      format.ics 

    end
  end
end

and index.ics.builer

RiCal.Calendar do
    event do
      description "MA-6 First US Manned Spaceflight"
      dtstart     DateTime.parse("2/20/1962 14:47:39")
      dtend       DateTime.parse("2/20/1962 19:43:02")
      location    "Cape Canaveral"
      add_attendee "john.glenn@nasa.gov"
      alarm do
        description "Segment 51"
      end
    end
  end


I was able to succeed in getting an ICS created by

def index
 cal =RiCal.Calendar do
   event do
     description "MA-6 First US Manned Spaceflight"
     dtstart DateTime.parse("1962-02-20")
     dtend DateTime.parse("1962-02-20")
     location "Cape Canaveral"
     add_attendee "john.glenn@nasa.gov"
     alarm do
       description "Segment 51"
     end
   end
 end
 respond_to do |format|
  format.ics { send_data(cal.export, :filename=>"mycal.ics", :disposition=>"inline; filename=mycal.ics", :type=>"text/calendar")}
 end
end

no need for the discrete builder

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜