我使用Rails 4和MongoDB作为我项目的数据库。我正在使用“devise”gem创建登录,但我无法找到与Rails 4兼容的MongoMapper版本。我收到以下错误:
/app/models/user.rb:3:in `<class:User>': uninitialized constant MongoMapper::Devise (NameError),
rom /home/rails/Projects/synergy/app/models/user.rb:1:in `<top (required)>'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/inflector/methods.rb:226:in `const_get'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/inflector/methods.rb:226:in `block in constantize'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/inflector/methods.rb:224:in `each'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/inflector/methods.rb:224:in `inject'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/inflector/methods.rb:224:in `constantize'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise.rb:297:in `get'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/mapping.rb:77:in `to'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/mapping.rb:72:in `modules'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/mapping.rb:89:in `routes'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/mapping.rb:156:in `default_used_route'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/mapping.rb:66:in `initialize'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise.rb:331:in `new'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise.rb:331:in `add_mapping'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/rails/routes.rb:218:in `block in devise_for'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/rails/routes.rb:217:in `each'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/rails/routes.rb:217:in `devise_for'
from /home/rails/Projects/synergy/config/routes.rb:5:in `block in <top (required)>'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.1/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.1/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.1/lib/action_dispatch/routing/route_set.rb:319:in `draw'
from /home/rails/Projects/synergy/config/routes.rb:1:in `<top (required)>'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:40:in `each'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/file_update_checker.rb:75:in `call'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/file_update_checker.rb:75:in `execute'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:27:in `updater'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/initializable.rb:30:in `instance_exec'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/initializable.rb:30:in `run'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/rails/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from /home/rails/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
from /home/rails/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from /home/rails/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from /home/rails/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:180:in `each'
from /home/rails/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from /home/rails/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/initializable.rb:54:in `run_initializers'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application.rb:215:in `initialize!'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/rails/Projects/synergy/config/environment.rb:5:in `<top (required)>'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application.rb:189:in `require_environment!'
from /home/rails/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/commands.rb:44:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>
如何将MongoMapper与Rails 4一起使用?
答案 0 :(得分:3)
最新版本的设计似乎只支持mongoid和活动记录的ORM。
https://github.com/plataformatec/devise/tree/master/lib/devise/orm
有一些宝石可能会有所帮助,但它们已经过时,可能无法使用最新的设计/ mongomapper。
如果你必须使用mongodb,那么使用支持的mongoid驱动程序(而不是mongomapper)。