简体   繁体   English

const_get': 未初始化的常量 AdminUser (NameError)

[英]const_get': uninitialized constant AdminUser (NameError)

I very new to ruby on rails, stuck with this error, below is the log file我对 ruby on rails 很陌生,遇到了这个错误,下面是日志文件

/Users/xyz/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.2/lib/active_support/inflector/methods.rb:261:in `const_get': uninitialized constant AdminUser (NameError)
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.2/lib/active_support/inflector/methods.rb:261:in `block in constantize'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.2/lib/active_support/inflector/methods.rb:259:in `each'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.2/lib/active_support/inflector/methods.rb:259:in `inject'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.2/lib/active_support/inflector/methods.rb:259:in `constantize'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise.rb:289:in `get'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise/mapping.rb:81:in `to'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise/mapping.rb:76:in `modules'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise/mapping.rb:93:in `routes'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise/mapping.rb:160:in `default_used_route'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise/mapping.rb:70:in `initialize'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise.rb:323:in `new'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise.rb:323:in `add_mapping'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise/rails/routes.rb:241:in `block in devise_for'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise/rails/routes.rb:240:in `each'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/devise-4.1.1/lib/devise/rails/routes.rb:240:in `devise_for'
    from /Users/xyz/rails_exp/doctorcall/config/routes.rb:3:in `block in <top (required)>'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.2/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.2/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.2/lib/action_dispatch/routing/route_set.rb:410:in `draw'
    from /Users/xyz/rails_exp/doctorcall/config/routes.rb:1:in `<top (required)>'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:40:in `each'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.2/lib/active_support/file_update_checker.rb:75:in `execute'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:27:in `updater'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `run'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `call'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/railties-4.2.2/lib/rails/application.rb:352:in `initialize!'
    from /Users/xyz/rails_exp/doctorcall/config/environment.rb:5:in `<top (required)>'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/spring-1.1.3/lib/spring/application.rb:92:in `preload'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/spring-1.1.3/lib/spring/application.rb:140:in `serve'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
    from /Users/xyz/.rvm/gems/ruby-2.3.0/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/xyz/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'

routes.rb路线.rb

Rails.application.routes.draw do
  devise_for :users
  devise_for :admin_users, ActiveAdmin::Devise.config
  ActiveAdmin.routes(self)
  root             'static_pages#home'
  get 'help'    => 'static_pages#help'
  get 'about'   => 'static_pages#about'
  get 'contact' => 'static_pages#contact'
  get 'signup'  => 'users#new'
  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"

  # Example of regular route:
  #   get 'products/:id' => 'catalog#view'

  # Example of named route that can be invoked with purchase_url(id: product.id)
  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

  # Example resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Example resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Example resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Example resource route with more complex sub-resources:
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', on: :collection
  #     end
  #   end

  # Example resource route with concerns:
  #   concern :toggleable do
  #     post 'toggle'
  #   end
  #   resources :posts, concerns: :toggleable
  #   resources :photos, concerns: :toggleable

  # Example resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end

  namespace :doctor do
    post 'login', to: 'authentication#login'
    post 'details', to: 'device#details'
    post 'logout', to: 'authentication#logout'
    post 'online', to: 'authentication#online'
    post 'offline', to: 'authentication#offline'
  end
end

how to solve this如何解决这个问题

It'old but I just got this issue I launched sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs 它已经老了,但我刚遇到这个问题,我启动了sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs

to complete missing packages 完成丢失的包裹

我不确定,但请更正本地根语法并检查:

root to: "static_pages#home"

[very old] You can generate that error if you: [非常旧] 如果您执行以下操作,则可能会产生该错误:

  • create the route devise_for for that class为 class 创建路由devise_for
  • before you run the scaffold command.运行脚手架命令之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NameError: 未初始化的常量 AdminUser - NameError: uninitialized constant AdminUser `const_get&#39;:uninitialized constant [class](NameError)`在带有Spring的Docker文件保存之后 - `const_get': uninitialized constant [class] (NameError)` after file save in Docker with Spring configuration.rb:140:in&#39;const_get&#39;:未初始化的常量ActionDispatch :: Session :: EncryptedCookieStore(NameError) - configuration.rb:140:in `const_get': uninitialized constant ActionDispatch::Session::EncryptedCookieStore (NameError) ActiveAdmin - 未初始化的常量AdminUser - ActiveAdmin - uninitialized constant AdminUser `const_missing': 未初始化的常量 (NameError) - 需要 - `const_missing': uninitialized constant (NameError) - Require `const_missing':未初始化的常量(NameError) - `const_missing': uninitialized constant (NameError) Rails模型和const_get - Rails models and const_get 在Heroku上部署Activeadmin时出现“未初始化的常量AdminUser” - “uninitialized constant AdminUser” when deploying Activeadmin on Heroku 如何摆脱未初始化的常量Omniauth(NameError)? - How to get rid of uninitialized constant Omniauth (NameError)? const_missing&#39;:未初始化的常量Rack :: IpRestrictor(NameError) - const_missing': uninitialized constant Rack::IpRestrictor (NameError)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM