private method `gsub' called for 0:Fixnum

来源:互联网 发布:win7连接网络打印机卡 编辑:程序博客网 时间:2024/05/18 16:40

gsub这个方法还不支持数字为属性值的标签转换……打开rexml文件夹下面的text.rb,找到代码,大概在289行

 

Ruby代码
  1. def Text::normalize( input, doctype=nil, entity_filter=nil )   
  2.       copy = input   
  3.       # Doing it like this rather than in a loop improves the speed   
  4.       #copy = copy.gsub( EREFERENCE, '&' )   
  5.       copy = copy.gsub( "&""&" )   
  6. ............省略后面的   

2种方法

 

1.修改Ruby,text.rb代码

        copy=input    =》         ruby = input.to_s  

2.直接将integer类型转换成string类型

解决!

原创粉丝点击