I am using the 0.5.5 version of the gcal4ruby gem on my rails 3.0 app and I am seemingly having trouble creating an event. I can start service, and create a calendar just fine, but I get the following error when I try to create an event:
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
I looked at the code in this line, and it seems like it is checking whether or not the service.debug = true, not the calendar, so i'm not sure why it is throwing this error. Here's how I got here in IRB, line by line:
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'
I must be missing something here, but I'm not sure what. Obviously I am getting a valid calendar object...is there some attribute that I am missing?
Alternatively, if anyone has any other suggestions as to what to use for a calendar solution I would love to hear it. Basically I need to allow users to add predefined events to a calendar, which can be recurring, and ideally I'd like for them to be able to export these calendars for use in outlook, ical, etc... Is there a way to do this via web?
Thanks!
well this is annoying, i seem to have it working. it was a matter of changing:
event = GCal4Ruby::Event.new(calendar)
to
event = GCal4Ruby::Event.new(service)
even though that's directly contrary to what i had read in the documentation.
精彩评论