【问题标题】:Rails 4 gem - ActiveSupport - method already definedRails 4 gem - ActiveSupport - 方法已经定义
【发布时间】:2013-12-11 05:13:31
【问题描述】:

我正在尝试使这个 gem (https://github.com/gshaw/common_validators) 与 Rails 4 兼容,但遇到了一些麻烦。

gemspec line 22 更改为spec.add_dependency "rails", ">= 3.2" 将产生一个错误

app/validators/date_format_validator.rb:8:in `<top (required)>': uninitialized constant ActiveModel (NameError)

看来我必须明确要求active_record,所以我已将require 'active_record' 添加到test_helper.rb

现在收到的错误是

/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/testing/declarative.rb:36:in `test': test_invalid_date is already defined in DateFormatValidatorTest (RuntimeError)

看起来我缺少一些基本的东西,但不确定是什么。我尝试了各种方法都无济于事。

非常感谢任何想法。谢谢!

【问题讨论】:

    标签: ruby ruby-on-rails-4 runtime-error activesupport


    【解决方案1】:

    实现work 的唯一方法是生成一个新的rails 插件,如http://guides.rubyonrails.org/plugins.html 所述,并从那里使用测试框架。

    【讨论】:

      猜你喜欢
      • 2016-08-27
      • 1970-01-01
      • 2021-02-12
      • 1970-01-01
      • 1970-01-01
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多