对任何事情调用“清理”方法会导致Rails 3中缺少方法错误,而集合创意的Money Gem
sanitize "trololo"
=>
undefined method `id2name' for {:instance_writer=>false}:Hash
collectiveidea-money (1.7.4) lib/support/cattr_accessor.rb:7:in `block in cattr_reader'
collectiveidea-money (1.7.4) lib/support/cattr_accessor.rb:5:in `each'
collectiveidea-money (1.7.4) lib/support/cattr_accessor.rb:5:in `cattr_reader'
collectiveidea-money (1.7.4) lib/support/cattr_accessor.rb:54:in `cattr_accessor'
actionpack (3.2.8) lib/action_controller/vendor/html-scanner/html/sanitizer.rb:48:in `<class:LinkSanitizer>'
actionpack (3.2.8) lib/action_controller/vendor/html-scanner/html/sanitizer.rb:47:in `<module:HTML>'
actionpack (3.2.8) lib/action_controller/vendor/html-scanner/html/sanitizer.rb:5:in `<top (required)>'
actionpack (3.2.8) lib/action_view/helpers/sanitize_helper.rb:174:in `white_list_sanitizer'
actionpack (3.2.8) lib/action_view/helpers/sanitize_helper.rb:60:in `sanitize'
之前有没有人遇到此错误?
答案 0 :(得分:4)
在挖掘源代码后,我发现: money gem定义了cattr_accessor
辅助方法(参见文件YOUR_GEM_DIR / collectiveidea-money-1.7.4 / lib / support /cattr_accessor.rb)和active_support一样(参见文件YOUR_GEM_DIR / activesupport-3.2.8 / lib / active_support / core_ext / class / attribute_accessors.rb)。
不幸的是, money gem中的实现与active_support中的实现不同。在您的情况下, money gem已在active_support之后加载并覆盖* good * active_support实现。
您可以通过确保在active_support之前加载 money gem来“修复”它。如果您发布有关您的申请的更多详细信息,我可以告诉您如何做到这一点......
然而, money 宝石似乎已经过时了,所以我建议你用更近期和积极维护的东西替换它......