Ruby on rails rexml命名错误-';元素';零级:零级
我正在使用gdata ruby gem for Google API获取日历。 (根据) 问题是,即使日历提要具有有效的XML,我仍然会得到: NoMethodError(nil:NilClass的未定义方法“elements”): app/controllers/g_data_controller.rb:74:inRuby on rails rexml命名错误-';元素';零级:零级,ruby-on-rails,Ruby On Rails,我正在使用gdata ruby gem for Google API获取日历。 (根据) 问题是,即使日历提要具有有效的XML,我仍然会得到: NoMethodError(nil:NilClass的未定义方法“elements”): app/controllers/g_data_controller.rb:74:inblock in fetch_feed' app/controllers/g_data_controller.rb:63:infetch_feed' app/controllers/
block in fetch_feed'
app/controllers/g_data_controller.rb:63:in
fetch_feed'
app/controllers/g_data_controller.rb:122:in'index'
feed= @client.get(m.gcal_id).to_xml
if feed
entry=feed.elements['entry'] #Error on this line !
顺便说一句,我不确定这段代码是怎么回事,我正在使用rexml(正如google所建议的)来解析XMl元素。让我澄清一下,feed变量包含日历的有效XMl。在打印它们之后,我已经进行了检查。@client.get(m.gcal_id).to_xml似乎返回nil。如果没有更多的代码来显示它在做什么,就很难判断问题出在哪里ocurring@aperture-feed变量包含从-@client.get(m.gcal_id).to_XML的有效XML。我已经打印了XML值并进行了检查。不是零。