1

问题是有一个 ruby​​gem 向 RoR ActiveRecord 添加了一些语法糖,用于定义过滤器和订单。我们使用 meta_where,然后切换到 squeel 以获得 rails 3 支持。问题是 ActiveRecord <= 3.0.10 一切正常,现在当我尝试在 gem 中切换到 3.1.0 时,我收到了这个错误:

/Users/admin/.rvm/gems/ree-1.8.7-2011.03@filters/gems/activerecord-3.1.0/lib/active_record/named_scope.rb:194:in `valid_scope_name?': private method `warn' called for nil:NilClass (NoMethodError)

整个轨迹如下:

/Users/admin/.rvm/gems/ree-1.8.7-2011.03@filters/gems/activerecord-3.1.0/lib/active_record/named_scope.rb:194:in `valid_scope_name?': private method `warn' called for nil:NilClass (NoMethodError)
    from /Users/admin/.rvm/gems/ree-1.8.7-2011.03@filters/gems/activerecord-3.1.0/lib/active_record/named_scope.rb:175:in `scope'
    from ./test/simplificator_filter/filterable/filterable_test.rb:12
    from /Users/admin/.rvm/gems/ree-1.8.7-2011.03@filters/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
    from /Users/admin/.rvm/gems/ree-1.8.7-2011.03@filters/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
    from /Users/admin/.rvm/gems/ree-1.8.7-2011.03@filters/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/admin/.rvm/gems/ree-1.8.7-2011.03@filters/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
    from /Users/admin/.rvm/gems/ree-1.8.7-2011.03@filters/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/admin/.rvm/gems/ree-1.8.7-2011.03@filters/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
    from /Users/admin/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
    from /Users/admin/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
    from /Users/admin/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5

耙中止!

我搜索了类似的错误,但一无所获(主要是痕迹)。有谁知道可能是什么问题?

先感谢您。干杯,内森

4

2 回答 2

1

重新加载模型时的行为已更改。虽然 3.0 不会打扰load 'app/models/post.rb'3.1 会引发此错误。当您喜欢在控制台上以交互方式优化模型时,您必须删除Object.send :remove_const, 'Post'之前的模型。

于 2011-10-13T16:10:22.550 回答
0

我设法修复它。

原来问题出在测试套件中。由于这个 gem 是关于添加一些语法糖来定义过滤器和命令,因此它干扰了 ActiveRecord。

显然这样做会在重新评估类或在测试用例中具有相同名称的类时导致问题,在删除一切正常之后。

于 2011-09-22T11:49:57.113 回答