mkeoid_fulltext错误,而rake db:create_indexes ...未定义方法`db'for#

时间:2013-03-25 05:04:32

标签: ruby-on-rails mongodb mongoid moped

使用rails和mongo-1.8.3,mongoid 3.1.2

我想组合多个字符串字段并创建一个full_text索引..但在初始设置期间我收到此错误

我的模型看起来像这样: -

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

  field :name, type: String
  fulltext_search_in :name

在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

1 个答案:

答案 0 :(得分:0)

低于0.6的

mongoid_fulltext版本与Mongoid 3(因此是Moped)不兼容。 更新mongoid_fulltext上面的错误就消失了