Rails 3 App中的Google日历

时间:2011-07-26 08:46:44

标签: ruby-on-rails ruby-on-rails-3 calendar google-calendar-api

我正在使用我的rails 3.0应用程序上的0.5.5 version of the gcal4ruby gem而我是 似乎在创建活动时遇到了麻烦。我可以开始服务了 创建一个日历就好了,但是当我尝试时出现以下错误 创建一个事件:

NoMethodError: undefined method `debug' for #<GCal4Ruby::Calendar: 
0x1036d8a68> 
        from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/ 
event.rb:242:in `to_xml' 
        from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/ 
event.rb:236:in `map' 
        from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/ 
event.rb:236:in `to_xml' 
        from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/ 
event.rb:230:in `create' 
        from /opt/local/lib/ruby/gems/1.8/gems/gdata4ruby-0.1.5/lib/ 
gdata4ruby/gdata_object.rb:155:in `save' 
        from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/ 
event.rb:225:in `save' 
        from (irb):92 

我查看了这一行中的代码,似乎正在检查 无论是service.debug = true,还是日历,所以我不是 确定为什么它会抛出这个错误。这是我在IRB的到来, 逐行:

service = GCal4Ruby::Service.new 
service.authenticate(MY_GOOGLE_LOGIN, MY_GOOGLE_PASS) 
calendar = GCal4Ruby::Calendar.find(service, 'Test 2', :first) 
event = GCal4Ruby::Event.new(calendar) 
event.title = "test title" 
event.content = "test content" 
event.where = "my house" 
event.start = Time.now 
event.end = 2.hours.from_now 
event.all_day = false 
event.calendar = calendar[0] 
event.save 
NoMethodError: undefined method `debug' for #<GCal4Ruby::Calendar: 
0x1036d9990> 
        from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/ 
event.rb:242:in `to_xml' 
        from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/ 
event.rb:236:in `map' 
        from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/ 
event.rb:236:in `to_xml' 
        from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/ 
event.rb:230:in `create' 
        from /opt/local/lib/ruby/gems/1.8/gems/gdata4ruby-0.1.5/lib/ 
gdata4ruby/gdata_object.rb:155:in `save' 
        from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/ 
event.rb:225:in `save' 

我必须在这里遗漏一些东西,但我不确定是什么。显然我 我得到一个有效的日历对象......我是否有一些属性 丢失?

或者,如果有人对日历解决方案的用途有任何其他建议,我很乐意听到。基本上我需要允许用户将预定义事件添加到日历中,这可以重复出现,理想情况下我希望他们能够导出这些日历以用于outlook,ical等...有没有办法通过网络做到这一点?

谢谢!

1 个答案:

答案 0 :(得分:1)

好吧,这很烦人,我似乎有它的工作。这是一个改变的问题:

event = GCal4Ruby::Event.new(calendar)

event = GCal4Ruby::Event.new(service)

即使这与我在文档中读到的内容完全相反。