私は別の同様の質問を見つけ、ここから参照された指示に従っていると思いますが、まだこのエラーに遭遇しています。
Rubyスクリプトで呼び出している指示に従ってMongoid.load!("path/to/your/mongoid.yml")
いるので、そうではないと思います。
からのエラー メッセージによると、inflector
CarrierDomain の定義方法に問題がある可能性があります。Sinatra スクリプトから Rails モデルを参照しています。これは、carrier_domain.rb というモデル ファイルにあり、クラスは CarrierDomain ( class CarrierDomain
) として定義されています。実際、クラス定義全体は次のとおりです (これは小さなものです)。
class CarrierDomain
include Mongoid::Document
embedded_in :carrier
field :country
field :name
field :prefix, default: ''
end
これが私が得ているエラーメッセージです:
/Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize': uninitialized constant CarrierDomain (NameError)
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `constantize'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/metadata.rb:606:in `klass'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/builder.rb:39:in `klass'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/builders/embedded/many.rb:25:in `block in build'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/builders/embedded/many.rb:23:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/builders/embedded/many.rb:23:in `build'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/accessors.rb:43:in `create_relation'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/accessors.rb:26:in `__build__'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/accessors.rb:156:in `block (3 levels) in getter'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/threaded/lifecycle.rb:125:in `_loading'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/accessors.rb:156:in `block (2 levels) in getter'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/threaded/lifecycle.rb:84:in `_building'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/accessors.rb:155:in `block in getter'
from /opt/cmf/app/models/carrier.rb:120:in `to_email_addresses'
from mta_connector.rb:151:in `block in <main>'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual/mongo.rb:645:in `yield_document'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual/mongo.rb:134:in `block (2 levels) in each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/query.rb:78:in `block in each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/cursor.rb:26:in `block in each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/cursor.rb:26:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/cursor.rb:26:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/query.rb:77:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/query.rb:77:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual/mongo.rb:133:in `block in each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual/mongo.rb:604:in `selecting'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual/mongo.rb:132:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual.rb:18:in `each'
from mta_connector.rb:139:in `<main>'