我正在尝试使用以下方法来覆盖 base_helper.rb 的帮助程序方法:
module Spree
module BaseHelper.class_eval do
def taxons_tree(root_taxon, current_taxon, max_level = 1)
.....
end
end
end
它对我不起作用。有人知道我在这里错过了什么吗?
谢谢!
固定:
我应该使用:
Spree::BaseHelper.module_eval do
def taxons_tree(root_taxon, current_taxon, max_level = 1)
...
end
end
相反。
重新打开模块也可以正常工作:
module Spree
module BaseHelper
def taxons_tree(root_taxon, current_taxon, max_level = 1)
...
end
end
end
没有特别的理由使用class_eval
和module_eval
,这只是Spree项目中很长一段时间的习惯。