[RUBY] [Resolve LoadError] Unable to autoload constant HomeController, expected /home/vagrant/work/bookers1_debug/app/controllers/home_controller.rb to define it

error contents

LodeError

Unable to autoload constant HomeController, expected /home/vagrant/work/bookers1_debug/app/controllers/home_controller.rb to define it



        else
          require_or_load(expanded, qualified_name)
          raise LoadError, "Unable to autoload constant #{qualified_name}, expected #{file_path} to define it" unless from_mod.const_defined?(const_name, false)
          return from_mod.const_get(const_name)
        end
      elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix)


`Rails.root: /home/vagrant/work/bookers1_debug`

Application Trace | Framework Trace | Full Trace activesupport (5.2.4.3) lib/active_support/dependencies.rb:511:in load_missing_constant' bootsnap (1.4.6) lib/bootsnap/load_path_cache/core_ext/active_support.rb:61:in block in load_missing_constant' bootsnap (1.4.6) lib/bootsnap/load_path_cache/core_ext/active_support.rb:17:in allow_bootsnap_retry' bootsnap (1.4.6) lib/bootsnap/load_path_cache/core_ext/active_support.rb:60:in load_missing_constant' activesupport (5.2.4.3) lib/active_support/dependencies.rb:195:in const_missing' activesupport (5.2.4.3) lib/active_support/inflector/methods.rb:283:in const_get' activesupport (5.2.4.3) lib/active_support/inflector/methods.rb:283:in block in constantize' activesupport (5.2.4.3) lib/active_support/inflector/methods.rb:281:in each' activesupport (5.2.4.3) lib/active_support/inflector/methods.rb:281:in inject' activesupport (5.2.4.3) lib/active_support/inflector/methods.rb:281:in constantize' activesupport (5.2.4.3) lib/active_support/dependencies.rb:582:in get' activesupport (5.2.4.3) lib/active_support/dependencies.rb:613:in constantize' actionpack (5.2.4.3) lib/action_dispatch/http/request.rb:88:in controller_class_for' actionpack (5.2.4.3) lib/action_dispatch/http/parameters.rb:101:in binary_params_for?' actionpack (5.2.4.3) lib/action_dispatch/http/parameters.rb:92:in set_binary_encoding' actionpack (5.2.4.3) lib/action_dispatch/http/parameters.rb:69:in path_parameters=' actionpack (5.2.4.3) lib/action_dispatch/journey/router.rb:50:in block in serve' actionpack (5.2.4.3) lib/action_dispatch/journey/router.rb:35:in each' actionpack (5.2.4.3) lib/action_dispatch/journey/router.rb:35:in serve' actionpack (5.2.4.3) lib/action_dispatch/routing/route_set.rb:840:in call' rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in call' rack (2.2.3) lib/rack/etag.rb:27:in call' rack (2.2.3) lib/rack/conditional_get.rb:27:in call' rack (2.2.3) lib/rack/head.rb:12:in call' actionpack (5.2.4.3) lib/action_dispatch/http/content_security_policy.rb:18:in call' rack (2.2.3) lib/rack/session/abstract/id.rb:266:in context' rack (2.2.3) lib/rack/session/abstract/id.rb:260:in call' actionpack (5.2.4.3) lib/action_dispatch/middleware/cookies.rb:670:in call' activerecord (5.2.4.3) lib/active_record/migration.rb:559:in call' actionpack (5.2.4.3) lib/action_dispatch/middleware/callbacks.rb:28:in block in call' activesupport (5.2.4.3) lib/active_support/callbacks.rb:98:in run_callbacks' actionpack (5.2.4.3) lib/action_dispatch/middleware/callbacks.rb:26:in call' actionpack (5.2.4.3) lib/action_dispatch/middleware/executor.rb:14:in call' actionpack (5.2.4.3) lib/action_dispatch/middleware/debug_exceptions.rb:61:in call' web-console (3.7.0) lib/web_console/middleware.rb:135:in call_app' web-console (3.7.0) lib/web_console/middleware.rb:22:in block in call' web-console (3.7.0) lib/web_console/middleware.rb:20:in catch' web-console (3.7.0) lib/web_console/middleware.rb:20:in call' actionpack (5.2.4.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in call' railties (5.2.4.3) lib/rails/rack/logger.rb:38:in call_app' railties (5.2.4.3) lib/rails/rack/logger.rb:26:in block in call' activesupport (5.2.4.3) lib/active_support/tagged_logging.rb:71:in block in tagged' activesupport (5.2.4.3) lib/active_support/tagged_logging.rb:28:in tagged' activesupport (5.2.4.3) lib/active_support/tagged_logging.rb:71:in tagged' railties (5.2.4.3) lib/rails/rack/logger.rb:26:in call' sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in call' actionpack (5.2.4.3) lib/action_dispatch/middleware/remote_ip.rb:81:in call' actionpack (5.2.4.3) lib/action_dispatch/middleware/request_id.rb:27:in call' rack (2.2.3) lib/rack/method_override.rb:24:in call' rack (2.2.3) lib/rack/runtime.rb:22:in call' activesupport (5.2.4.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in call' actionpack (5.2.4.3) lib/action_dispatch/middleware/executor.rb:14:in call' actionpack (5.2.4.3) lib/action_dispatch/middleware/static.rb:127:in call' rack (2.2.3) lib/rack/sendfile.rb:110:in call' railties (5.2.4.3) lib/rails/engine.rb:524:in call' puma (3.12.6) lib/puma/configuration.rb:227:in call' puma (3.12.6) lib/puma/server.rb:706:in handle_request' puma (3.12.6) lib/puma/server.rb:476:in process_client' puma (3.12.6) lib/puma/server.rb:334:in block in run' puma (3.12.6) lib/puma/thread_pool.rb:135:in block in spawn_thread'


# Cause
 The class name of home_controller.rb was Controller.
 In routes.rb, the controller name is useless even though it is home # top.

Controller
=>
HomeController


 ▼ Reference
https://okerablog.com/2018-01-03-082902/
https://stackoverrun.com/ja/q/8095183a

# Deep digging
 Apparently, when launching the application, ActionDispatch middleware (? I don't know what the middleware is) is working in rails.
### What kind of work
 Providing routes from routes.rb to controller.rb and much more.

 So this time, I wonder if the Controller side did not bridge well from routes.
 ▼ Reference: About #ActionDispatch
https://blog.eiel.info/blog/2014/03/30/action-dispatch/



Recommended Posts

[Resolve LoadError] Unable to autoload constant HomeController, expected /home/vagrant/work/bookers1_debug/app/controllers/home_controller.rb to define it
ERESOLVE unable to resolve dependency tree