如何使用 Rails 和 ri_cal 创建 .ics 文件?

发布于 2024-09-26 04:51:11 字数 801 浏览 2 评论 0原文

我正在使用 Rails 3 和 ri_cal gem。我无法生成有效的 .ics 文件。它已生成,但 AppleCalendar 或 GoogleCalendar 说它是空的。我做错了什么? 感谢帮助,提前致谢:)

我的控制器

class WebsitesController < ApplicationController
  def index

    respond_to do |format|

      format.ics 

    end
  end
end

和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 "[email protected]"
      alarm do
        description "Segment 51"
      end
    end
  end

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 < ApplicationController
  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 "[email protected]"
      alarm do
        description "Segment 51"
      end
    end
  end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烙印 2024-10-03 04:51:11

我能够成功地创建 ICS,而

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 "[email protected]"
     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

无需离散构建器

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 "[email protected]"
     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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文