gpt4 book ai didi

ruby-on-rails - 如何在带有 Rails 4 版本的 mongodb 中使用 "devise"gem?

转载 作者:可可西里 更新时间:2023-11-01 10:04:36 24 4
gpt4 key购买 nike

我使用 Rails 4 和 MongoDB 作为我项目的数据库。我正在使用“设计”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>

如何在 Rails 4 中使用 MongoMapper?

最佳答案

devise 的最新版本似乎只有对 mongoid 和 active record 的 ORM 支持。

https://github.com/plataformatec/devise/tree/master/lib/devise/orm

有一些 gems 可能会有所帮助,但它们已经过时并且可能无法与最新的 devise/mongomapper 一起使用。

如果您必须使用 mongodb,则使用受支持的 mongoid 驱动程序(而不是 mongomapper)。

关于ruby-on-rails - 如何在带有 Rails 4 版本的 mongodb 中使用 "devise"gem?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20635671/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com