在 Ironworker 文件上使用 mongoid 和 Sql 时出现 ActiveRecord 错误



(我对Rails比较陌生)

我有一个文件(Ruby),我正在通过Ironworkers运行/上传,该文件当前正在使用MySql(activeRecord)作为数据库。 ALl 工作正常,但我们现在需要一个新的(附加的)模型,它将使用 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已弃用,将被删除而不进行替换。(从 set_table_name/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:660 调用) 弃用警告: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:indefine_method_attribute' 来自/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/attribute_methods/time_zone_conversion.rb:35:indefine_method_attribute' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:267:in块在define_attribute_method' 来自/task/gems/activemodel/lib/active_model/attribute_methods.rb:260:ineach' 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:inblock in define_attribute_methods' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:256:in来自/task/gems/activemodel/lib/active_model/attribute_methods.rb:256:INdefine_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:INrespond_to?' from /task/gems/activesupport/lib/active_support/callbacks.rb:398:in__run_callback' from/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' from/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:1617:ininit_with' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:959:ininstanceiate' 来自/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:470:INblock in find_by_sql' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:470:in收集! 来自/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:470:infind_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:infind_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:infind_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:innew_user_setup' from /task/user_setup.rb:39:ininitialize' from/task/justa_worker.rb:48:innew' from /task/justa_worker.rb:48:inrun' from/task/runner.rb:405:in ''

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

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

尝试:

  1. 再次检查实际使用的 gem 版本
  2. 手动设置精确版本(merge_gem中的第二个参数)
  3. 在 ruby 代码中的某个地方使用神奇的结构gem 'mygem', '=0.1.2'

相关内容

  • 没有找到相关文章

最新更新