2012-03-02 71 views
1

我on Rails的3.1to_xml总是抛出错误

我已经粘贴下面的例子,但调用to_xml上任何模型抛出这个错误。我已经尝试了一切,但我是之前有人会看到的那种东西。它是否为任何人敲响了任何铃声?

1.8.7 :004 > Person.first.to_xml 
    Person Load (2.0ms) SELECT `people`.* FROM `people` LIMIT 1 
ArgumentError: wrong number of arguments (1 for 0) 
    from /home/khughes/.rvm/gems/[email protected]/gems/builder-3.0.0/lib/builder/xmlbase.rb:135:in `to_xs' 
    from /home/khughes/.rvm/gems/[email protected]/gems/builder-3.0.0/lib/builder/xmlbase.rb:135:in `_escape' 
    from /home/khughes/.rvm/gems/[email protected]/gems/builder-3.0.0/lib/builder/xmlbase.rb:140:in `_escape_quote' 
    from /home/khughes/.rvm/gems/[email protected]/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:320:in `_attr_value' 
    from /home/khughes/.rvm/gems/[email protected]/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:308:in `_insert_attributes' 
    from /home/khughes/.rvm/gems/[email protected]/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:306:in `each' 
    from /home/khughes/.rvm/gems/[email protected]/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:306:in `_insert_attributes' 
    from /home/khughes/.rvm/gems/[email protected]/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:284:in `_special' 
    from /home/khughes/.rvm/gems/[email protected]/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:250:in `instruct!' 
    from /home/khughes/.rvm/gems/[email protected]/gems/activemodel-3.1.1/lib/active_model/serializers/xml.rb:93:in `serialize' 
    from /home/khughes/.rvm/gems/[email protected]/gems/activerecord-3.1.1/lib/active_record/serializers/xml_serializer.rb:175:in `to_xml' 
    from (irb):4 

回答

1

前段时间有同样的问题,您是否将hpricot gem捆绑到项目中?如果是的话,尝试从Gemfile中删除,运行bundle并检查是否to_xml工作

还有为我工作的解决方案: https://github.com/hpricot/hpricot/issues/53(见smeevil的帖子)

+0

这就是它!谢谢,我不认为我会记录下来。 – 2012-03-02 10:38:18

相关问题