如何从日历邀请邮件中查看ics文件?

时间:2013-08-08 07:19:50

标签: ruby-on-rails ruby rubygems actionmailer icalendar

在我的invite.ics文件中,我看到的只是日历对象#<Icalendar::Calendar:0xb299a54> 我也试过实现这个link,但我得到了与该对象相同的.ics文件。我是红宝石的新手。任何人都可以向我推荐一个更好的教程,发送日历邀请谷歌日历,展望,ical。 这是迄今为止的代码。

class MeetingNotification < ActionMailer::Base
  # include Icalendar
   def meeting_request_with_calendar
     mail(:to => "ashi_12@gmail.com", :subject => "iCalendar",
                  :from => "tester@gmail.com") do |format|
       format.ics {
       ical = Icalendar::Calendar.new
       e = Icalendar::Event.new
       e.start = DateTime.now.utc
       e.start.icalendar_tzid="UTC" # set timezone as "UTC"
       e.end = (DateTime.now + 1.day).utc
       e.end.icalendar_tzid="UTC"
       e.organizer "tester@gmail.com"
       e.uid "MeetingRequest"
       e.summary "Scrum Meeting"
       e.description <<-EOF
         Venue: Office
         Date: 16 August 2013
         Time: 10 am
       EOF
       ical.add_event(e)
       ical.publish
       ical.to_ical
       render :text => ical, :layout => false
      }
    end
  end

1 个答案:

答案 0 :(得分:3)

我可能来不及回答..我有同样的问题。我使用render方法调用to_ical来修复它。试试这个

render :text => ical.to_ical