Uninitialized constant in document.rb:19
Closed this issue · 3 comments
seanhagen commented
When I try to run 'rake db:mongoid:create_indexes' I get the following error:
uninitialized constant Mongoid::Spacial::Document::ClassMethods::Mongo
MONGOID: Attempted to constantize Location, trying without namespacing.
MONGOID: Failed to determine model from app/models/location.rb:
NameError:uninitialized constant Mongoid::Spacial::Document::ClassMethods::Mongo
/home/sean/.bundler/ruby/1.9.1/mongoid_spacial-f45dd87c78fc/lib/mongoid_spacial/spacial/document.rb:19:in `spacial_index'
/app/models/location.rb:14:in `<class:Location>'
/app/models/location.rb:1:in `<top (required)>'
/var/lib/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize'
/var/lib/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `each'
/var/lib/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `constantize'
/var/lib/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
/var/lib/gems/1.9.1/gems/mongoid-3.0.14/lib/rails/mongoid.rb:149:in `rescue in determine_model'
/var/lib/gems/1.9.1/gems/mongoid-3.0.14/lib/rails/mongoid.rb:143:in `determine_model'
/var/lib/gems/1.9.1/gems/mongoid-3.0.14/lib/rails/mongoid.rb:67:in `block in models'
/var/lib/gems/1.9.1/gems/mongoid-3.0.14/lib/rails/mongoid.rb:64:in `map'
/var/lib/gems/1.9.1/gems/mongoid-3.0.14/lib/rails/mongoid.rb:64:in `models'
/var/lib/gems/1.9.1/gems/mongoid-3.0.14/lib/rails/mongoid.rb:19:in `create_indexes'
/var/lib/gems/1.9.1/gems/mongoid-3.0.14/lib/mongoid/railties/database.rake:74:in `block (4 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/mongoid-3.0.14/lib/mongoid/railties/database.rake:73:in `each'
/var/lib/gems/1.9.1/gems/mongoid-3.0.14/lib/mongoid/railties/database.rake:73:in `block (3 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:227:in `call'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:227:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:222:in `each'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:222:in `execute'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:152:in `invoke'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:141:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `each'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:108:in `run_with_threads'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:93:in `top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:71:in `block in run'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:158:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:68:in `run'
/var/lib/gems/1.9.1/gems/rake-10.0.2/bin/rake:37:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'
This is the class I'm attempting to use the gem in:
class Location
include Mongoid::Document
include Mongoid::Spacial::Document
belongs_to :neighbourhood
embeds_many :vehicles
field :loc, type: Array, spacial: true
field :name
field :description
spacial_index :loc
end
I tried change the name of the model class to NeighbourhoodLocation because of this error:
MONGOID: Attempted to constantize Location, trying without namespacing.
but that didn't seem to help.
jturolla commented
+1
LucasLazaro commented
+1
arthurnn commented
Closing the issue, as we have a PR for it.