2

(我对 Rails 比较陌生)

我有一个文件(Ruby)我正在通过 Ironworker 运行/上传,该文件当前使用 MySql(activeRecord)作为数据库。一切正常,但我们现在需要一个新的(附加)模型,它将使用 Mongoid,它也将包含在我们上传到 IronWorker 的代码中。当我在 IronWorker 文件中包含以下行 merge_gem 'mongoid' 时,我得到:

弃用警告:不再需要为属性方法指定空前缀/后缀。如果调用时没有定义方法的无前缀/后缀版本define_attribute_methods,则会自动定义。(从 /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/attribute_methods/read.rb:9 的块调用)

弃用警告:同步已弃用,将从 Rails 3.2 中删除。(从 /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:298 调用) 弃用警告:define_attr_method 已弃用,将被删除替代品。(从 /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:660 处的 set_table_name 调用) 弃用警告:define_attr_method 已弃用,将被删除而无需替换。(从 /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/locking/optimistic.rb:150 的 set_locking_column 调用)/usr/lib/ruby/gems/1.9.1 /gems/activerecord-3.1.6/lib/active_record/attribute_methods/read.rb:82:indefine_read_method': uninitialized constant ActiveModel::AttributeMethods::COMPILABLE_REGEXP (NameError) from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/attribute_methods/read.rb:42:in来自/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/attribute_methods/time_zone_conversion.rb:35的define_method_attribute' define_method_attribute' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:267:in:在/task/gems/activemodel/lib的define_attribute_method'块中/active_model/attribute_methods.rb:260:in each' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:260:indefine_attribute_method' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:256:in block in define_attribute_methods' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:256:ineach' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:256 :in define_attribute_methods' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/attribute_methods.rb:14:indefine_attribute_methods' 来自 /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/attribute_methods.rb:65:in respond_to?' from /task/gems/activesupport/lib/active_support/callbacks.rb:398:in__run_callback' 来自 /task/gems/activesupport/lib/active_support /callbacks.rb:385:in_run_find_callbacks' from /task/gems/activesupport/lib/active_support/callbacks.rb:81:inrun_callbacks' 来自 /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:1617:in init_with' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:959:ininstantiate' 来自 /usr/lib/ruby/gems/1.9.1 /gems/activerecord-3.1.6/lib/active_record/base.rb:470:in block in find_by_sql' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:470:incollect!' 来自 /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:470:in find_by_sql' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/relation.rb:112:into_a' 来自 /usr/lib/ruby/gems/1.9.1/gems /activerecord-3.1.6/lib/active_record/relation/finder_methods.rb:376:in find_first' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/relation/finder_methods.rb:122:infirst' 来自 /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/relation/ finder_methods.rb:263:in find_by_attributes' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:1070:inmethod_missing' from /task/user_setup.rb:74:in new_user_setup' from /task/user_setup.rb:39:ininitialize' from /task/justa_worker.rb:48:in new' from /task/justa_worker.rb:48:inrun' from /task/runner.rb:405:in `'

4

1 回答 1

4

首先,iron_worker gem 不久前被弃用了。如果可以的话,将您的代码更新为 iron_worker_ng gem ( https://github.com/iron-io/iron_worker_ruby_ng )。此操作将解决 99.9% 合并 gem 的问题(这是编写新 gem 的主要原因)

可能的原因:gem 版本不匹配,主要是 rails gems。主动记录/主动支持/等

尝试:

  1. 再次检查实际使用的 gem 版本
  2. 手动设置精确版本(merge_gem 中的第二个参数)
  3. gem 'mygem', '=0.1.2'在 ruby​​ 代码中的某处使用魔法构造
于 2012-10-19T09:56:34.507 回答