Hpricot - 未定义的方法“to_sym”对于 nil:NilClass
我最近做了一次捆绑更新,最终破坏了很多东西。我无法解决的问题之一是使用 hpricot 来格式化文本。
之前有 hpricot 用户遇到过这个 to_sym for nilClass 错误吗?谢谢
错误:
ActionView::Template::Error (undefined method `to_sym' for nil:NilClass):
config/initializers/hpricot_text_transform.rb:11:in `text_transform!'
config/initializers/hpricot_text_transform.rb
# By Henrik Nyh <http://henrik.nyh.se> 2007-03-28.
# Based on http://vemod.net/code/hpricot_goodies/hpricot_text_gsub.rb.
# Licensed under the same terms as Ruby.
require "rubygems"
require "hpricot"
module HpricotTextTransform
module NodeWithChildrenExtension
def text_transform!(options={}, &block)
return if defined?(name) and Array(options[:except]).include?(name.to_sym)
children.each { |c| c.text_transform!(options, &block) }
end
end
module TextNodeExtension
def text_transform!(options={}, &block)
content.replace yield(content)
end
end
module BogusETagExtension
def text_transform!(options={}, &block)
end
end
end
Hpricot::Doc.send(:include, HpricotTextTransform::NodeWithChildrenExtension)
Hpricot::Elem.send(:include, HpricotTextTransform::NodeWithChildrenExtension)
Hpricot::BogusETag.send(:include, HpricotTextTransform::BogusETagExtension)
Hpricot::Text.send(:include, HpricotTextTransform::TextNodeExtension)
I recently did a bundle update which ended up breaking a lot of stuff. One of the things I haven't been able to resolve is with hpricot which I use to format text.
Any hpricot users ever get this to_sym for nilClass error before? thanks
Error:
ActionView::Template::Error (undefined method `to_sym' for nil:NilClass):
config/initializers/hpricot_text_transform.rb:11:in `text_transform!'
config/initializers/hpricot_text_transform.rb
# By Henrik Nyh <http://henrik.nyh.se> 2007-03-28.
# Based on http://vemod.net/code/hpricot_goodies/hpricot_text_gsub.rb.
# Licensed under the same terms as Ruby.
require "rubygems"
require "hpricot"
module HpricotTextTransform
module NodeWithChildrenExtension
def text_transform!(options={}, &block)
return if defined?(name) and Array(options[:except]).include?(name.to_sym)
children.each { |c| c.text_transform!(options, &block) }
end
end
module TextNodeExtension
def text_transform!(options={}, &block)
content.replace yield(content)
end
end
module BogusETagExtension
def text_transform!(options={}, &block)
end
end
end
Hpricot::Doc.send(:include, HpricotTextTransform::NodeWithChildrenExtension)
Hpricot::Elem.send(:include, HpricotTextTransform::NodeWithChildrenExtension)
Hpricot::BogusETag.send(:include, HpricotTextTransform::BogusETagExtension)
Hpricot::Text.send(:include, HpricotTextTransform::TextNodeExtension)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试替换
为
Try replacing
with