(我对Rails相对较新)
我有一个文件(Ruby)我正在通过Ironworker运行/上传,目前正在使用MySql(activeRecord)作为数据库。 ALl工作正常,但我们现在需要一个新的(附加)模型,它将使用Mongoid,它也将包含在我们上传到IronWorker的代码中。 当我将以下行merge_gem'mongoid'包含在我的IronWorker文件中时,我得到:
DEPRECATION WARNING:不再需要为属性方法指定空前缀/后缀。如果在调用
define_attribute_methods
时尚未定义方法的未加前缀/后缀的版本,则会自动定义该版本。 (在/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/attribute_methods/read.rb:9中从块中调用)
DEPRECATION WARNING:不推荐使用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)
弃用警告:不推荐使用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: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
define_method_attribute'
来自/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.6/lib/active_record/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'
来自/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'
来自/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
每个'
来自/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
define_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:in
run_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:in
instantiate'
来自/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
收集!'
来自/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
to_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:in
first'
来自/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:in
method_missing'
来自/task/user_setup.rb:74:in new_user_setup'
from /task/user_setup.rb:39:in
initialize'
来自/task/justa_worker.rb:48:in new'
from /task/justa_worker.rb:48:in
运行'
来自/task/runner.rb:405:在''
答案 0 :(得分:4)
首先,iron_worker gem暂时弃用了。如果可以,请将您的代码更新为iron_worker_ng gem(https://github.com/iron-io/iron_worker_ruby_ng)。这个动作将解决合并宝石的99.9%问题(这是编写新宝石的主要原因)
可能原因:宝石版本不匹配,多为铁轨宝石。了activerecord /的ActiveSupport /等
尝试:
gem 'mygem', '=0.1.2'