Home > database >  Rails losing inheritance of Application controller
Rails losing inheritance of Application controller

Time:07-26

After conducting a set of changes to migration, dropping, re-creating and, migrating and loading data, while Unit test are running and passing as expected, controller tests have stopped running and fail because of:

uninitialized constant ApplicationController (NameError)

class MunicipalsController < ApplicationController

    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-7.0.3/lib/rails/test_unit/runner.rb:47:in `block in load_tests'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-7.0.3/lib/rails/test_unit/runner.rb:47:in `each'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-7.0.3/lib/rails/test_unit/runner.rb:47:in `load_tests'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-7.0.3/lib/rails/test_unit/runner.rb:40:in `run'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-7.0.3/lib/rails/commands/test/test_command.rb:33:in `perform'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-7.0.3/lib/rails/command/base.rb:87:in `perform'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-7.0.3/lib/rails/command.rb:48:in `invoke'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-7.0.3/lib/rails/commands.rb:18:in `<main>'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /Users/main/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'

It is as if the application see the app/controllers/application_controller.rb file - which was unaltered by the changes -

class ApplicationController < ActionController::Base
  include UniversalMethods

as having a different name. Possible corruption?

What can be done to get the process running anew?

Note: the application is running as expected, based on preliminary observations...

CodePudding user response:

Try closing all your workers and stopping spring with spring stop. If that doesn't work, you can try restarting your terminal.

  • Related