to_xml总是抛出错误

时间:2012-03-02 10:02:55

标签: ruby-on-rails ruby ruby-on-rails-3.1

我在Rails 3.1上

我在下面粘贴了一个示例,但在任何模型上调用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/ree-1.8.7-2012.02@rails31/gems/builder-3.0.0/lib/builder/xmlbase.rb:135:in `to_xs'
    from /home/khughes/.rvm/gems/ree-1.8.7-2012.02@rails31/gems/builder-3.0.0/lib/builder/xmlbase.rb:135:in `_escape'
    from /home/khughes/.rvm/gems/ree-1.8.7-2012.02@rails31/gems/builder-3.0.0/lib/builder/xmlbase.rb:140:in `_escape_quote'
    from /home/khughes/.rvm/gems/ree-1.8.7-2012.02@rails31/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:320:in `_attr_value'
    from /home/khughes/.rvm/gems/ree-1.8.7-2012.02@rails31/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:308:in `_insert_attributes'
    from /home/khughes/.rvm/gems/ree-1.8.7-2012.02@rails31/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:306:in `each'
    from /home/khughes/.rvm/gems/ree-1.8.7-2012.02@rails31/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:306:in `_insert_attributes'
    from /home/khughes/.rvm/gems/ree-1.8.7-2012.02@rails31/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:284:in `_special'
    from /home/khughes/.rvm/gems/ree-1.8.7-2012.02@rails31/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:250:in `instruct!'
    from /home/khughes/.rvm/gems/ree-1.8.7-2012.02@rails31/gems/activemodel-3.1.1/lib/active_model/serializers/xml.rb:93:in `serialize'
    from /home/khughes/.rvm/gems/ree-1.8.7-2012.02@rails31/gems/activerecord-3.1.1/lib/active_record/serializers/xml_serializer.rb:175:in `to_xml'
    from (irb):4

1 个答案:

答案 0 :(得分:1)

前一段时间有同样的问题,你有没有hpricot gem捆绑到项目中?如果是这样,尝试将其从Gemfile中删除,运行bundle并检查to_xml是否有效

有一个适合我的解决方案: https://github.com/hpricot/hpricot/issues/53(请参阅smeevil的帖子)