我曾经使用过Devise一百万次,但我从未遇到过这个问题。我已将gem放入我的gem文件中。我做了'捆绑安装',然后输入'rails generate devise:install',我收到了这个错误:
/Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/inflector/methods.rb:268:in `const_get': uninitialized constant User (NameError)
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/inflector/methods.rb:268:in `block in constantize'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/inflector/methods.rb:266:in `each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/inflector/methods.rb:266:in `inject'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/inflector/methods.rb:266:in `constantize'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise.rb:305:in `get'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/mapping.rb:81:in `to'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/mapping.rb:76:in `modules'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/mapping.rb:93:in `routes'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/mapping.rb:160:in `default_used_route'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/mapping.rb:70:in `initialize'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise.rb:335:in `new'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise.rb:335:in `add_mapping'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/rails/routes.rb:241:in `block in devise_for'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/rails/routes.rb:240:in `each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/rails/routes.rb:240:in `devise_for'
from /Users/johnseabolt/Desktop/2. Projects/ReactBlog/config/routes.rb:2:in `block in <top (required)>'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:389:in `instance_exec'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:389:in `eval_block'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:371:in `draw'
from /Users/johnseabolt/Desktop/2. Projects/ReactBlog/config/routes.rb:1:in `<top (required)>'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/file_update_checker.rb:77:in `execute'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/finisher.rb:119:in `block in <module:Finisher>'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `run'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application.rb:352:in `initialize!'
from /Users/johnseabolt/Desktop/2. Projects/ReactBlog/config/environment.rb:5:in `<top (required)>'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application.rb:92:in `preload'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application.rb:143:in `serve'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application.rb:131:in `block in run'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application.rb:125:in `loop'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application.rb:125:in `run'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
我以前已经过了这一步,但我转过身来再试一次。我已经运行'rails generate devise User',但收到了一个错误。如果我再次运行相同的命令,我会得到这个:
/Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/inflector/methods.rb:268:in `const_get': uninitialized constant User (NameError)
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/inflector/methods.rb:268:in `block in constantize'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/inflector/methods.rb:266:in `each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/inflector/methods.rb:266:in `inject'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/inflector/methods.rb:266:in `constantize'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise.rb:305:in `get'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/mapping.rb:81:in `to'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/mapping.rb:76:in `modules'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/mapping.rb:93:in `routes'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/mapping.rb:160:in `default_used_route'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/mapping.rb:70:in `initialize'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise.rb:335:in `new'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise.rb:335:in `add_mapping'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/rails/routes.rb:241:in `block in devise_for'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/rails/routes.rb:240:in `each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.1/lib/devise/rails/routes.rb:240:in `devise_for'
from /Users/johnseabolt/Desktop/2. Projects/ReactBlog/config/routes.rb:2:in `block in <top (required)>'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:389:in `instance_exec'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:389:in `eval_block'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:371:in `draw'
from /Users/johnseabolt/Desktop/2. Projects/ReactBlog/config/routes.rb:1:in `<top (required)>'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/file_update_checker.rb:77:in `execute'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application/finisher.rb:119:in `block in <module:Finisher>'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `run'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application.rb:352:in `initialize!'
from /Users/johnseabolt/Desktop/2. Projects/ReactBlog/config/environment.rb:5:in `<top (required)>'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application.rb:92:in `preload'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application.rb:143:in `serve'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application.rb:131:in `block in run'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application.rb:125:in `loop'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application.rb:125:in `run'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
有人可以帮忙吗?我似乎无法通过这个基本设置阶段。
答案 0 :(得分:0)
您的错误显示您尚未在routes.rb中添加devise_for :user
,如下所示:
from /Users/johnseabolt/Desktop/2. Projects/ReactBlog/config/routes.rb:2:in `<top (required)>'
从routes.rb中删除devise_for :user
,运行安装生成器,然后再次添加devise_for :user
。