ruby-on-railsmongodbmongoidmoped

mongoid_fulltext error while rake db:create_indexes... undefined method `db' for #<Moped::Collection


using rails along with mongo-1.8.3, mongoid 3.1.2

i want to combine many string fields and create one full_text index.. but during initial setup i am getting this error

my model looks like this:-

class User
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::FullTextSearch

  field :name, type: String
  fulltext_search_in :name

getting error on rake db:create_indexes

rake aborted!
undefined method `db' for #<Moped::Collection:0x007fba5c768f18>
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/mongoid_fulltext-       0.5.8/lib/mongoid_fulltext.rb:71:in `fulltext_search_ensure_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/mongoid_fulltext-0.5.8/lib/mongoid_fulltext.rb:66:in `block in create_fulltext_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/mongoid_fulltext-0.5.8/lib/mongoid_fulltext.rb:65:in `each_pair'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/mongoid_fulltext-0.5.8/lib/mongoid_fulltext.rb:65:in `create_fulltext_indexes'
 /Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/mongoid_fulltext-0.5.8/lib/mongoid_indexes.rb:7:in `create_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/mongoid-3.1.2/lib/rails/mongoid.rb:21:in `block in create_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/mongoid-3.1.2/lib/rails/mongoid.rb:18:in `each'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/mongoid-3.1.2/lib/rails/mongoid.rb:18:in `create_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/mongoid-3.1.2/lib/mongoid/railties/database.rake:71:in `block (3 levels) in <top (required)>'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/akhil/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/bin/rake:23:in `load'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194@rnd/bin/rake:23:in `<main>'
Tasks: TOP => db:mongoid:create_indexes

Solution

  • mongoid_fulltext versions below 0.6 are not compatible with Mongoid 3 (and therefore Moped). on updating mongoid_fulltext above error went away