2012-03-02 107 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