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

(我对Rails比较陌生)

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

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

DEPRECATION警告:synchronize已弃用,将从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处调用)DEPRECATION警告:define_attr_method已弃用,将被删除而不删除替代。 (从/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/base.rb:660处的set_table_name调用)DEPRECATION WARNING: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:in define_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/中的define_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 define_method_attribute' define_method_attribute' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:267:in中的“attribute_methods / time_zone_conversion.rb:35:in define_method_attribute' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:267:in define_attribute_method' 260:在each' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:260:in中的each' from /task/gems/activemodel/lib/active_model/attribute_methods.rb:260:in define_attribute_method' block in define_attribute_methods' 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:in define_attribute_methods' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/attribute_methods.rb:14:in从/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:in /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib的define_attribute_methods中/active_record/attribute_methods.rb:65:in respond_to?' from /task/gems/activesupport/lib/active_support/callbacks.rb:398:in respond_to?' from /task/gems/activesupport/lib/active_support/callbacks.rb:398:in _run_find_callbacks' from /task/gems/activesupport/lib/active_support/callbacks.rb:81:in respond_to?' from /task/gems/activesupport/lib/active_support/callbacks.rb:398:in _run_find_callbacks'中的/task/gems/activesupport/lib/active_support/callbacks.rb:398:in _run_find_callbacks' from /task/gems/activesupport/lib/active_support/callbacks.rb:81:in run_callbacks'from /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:in instantiate'from /usr/lib/ruby/gems/1.9.1/gems/activerecord -3.1.6 / lib / active_record / base.rb:470:在block in find_by_sql' from /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:in收集!' from /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:in /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/relation/finder_methods中的find_by_sql' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/relation.rb:112:in to_a'。 rb:376:在find_first' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/relation/finder_methods.rb:122:in首先从/ usr / lib /中find_first' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/relation/finder_methods.rb:122:in 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:in method_missing'from /task/user_setup.rb:74:in new_user_setup' from /task/user_setup.rb:39:in initialize': 48:在new' from /task/justa_worker.rb:48:in : new' from /task/justa_worker.rb:48:in :in`​​'


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

可能的原因:宝石版本不匹配,主要是铁轨宝石。 了activerecord /的ActiveSupport /等

尝试:

  • 再次检查实际使用的宝石版本
  • 手动设置确切版本(merge_gem中的第二个参数)
  • 在Ruby代码中使用魔法构造gem 'mygem', '=0.1.2'
  • 链接地址: http://www.djcxy.com/p/81123.html

    上一篇: getting ActiveRecord errors when using mongoid and Sql on Ironworker files

    下一篇: Syntax Error unexpected tANDOP on rails 3 Tutorial