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

时间:2016-06-17 10:48:27

标签: ruby-on-rails devise activeadmin

我对rails上的ruby很新,坚持这个错误, 下面是日志文件

/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

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

如何解决这个问题

2 个答案:

答案 0 :(得分:1)

但是我刚刚得到了这个问题 我推出了 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

完成缺失的包裹

答案 1 :(得分:0)

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

root to: "static_pages#home"