Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I changed the name of my controller and it broke administrate #2413

Open
ycha28 opened this issue Aug 7, 2023 · 1 comment
Open

I changed the name of my controller and it broke administrate #2413

ycha28 opened this issue Aug 7, 2023 · 1 comment
Labels
bug breakages in functionality that is implemented

Comments

@ycha28
Copy link

ycha28 commented Aug 7, 2023

I changed the name of a controller from "ReadOnlyDashboardController" to "ReadOnlyDashboardsController". This appears to have broken administrate's generator function, as I keep seeing this error when I run "rails g administrate:install"

/Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/administrate-0.19.0/lib/generators/administrate/dashboard/dashboard_generator.rb:140:in `klass': uninitialized constant ReadOnlyDashboard (NameError)

        @klass ||= Object.const_get(class_name)
                         ^^^^^^^^^^
Did you mean?  ReadOnlyDashboardHelper
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/administrate-0.19.0/lib/generators/administrate/dashboard/dashboard_generator.rb:62:in `attributes'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/administrate-0.19.0/lib/generators/administrate/dashboard/templates/dashboard.rb.erb:11:in `template'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/3.2.0/erb.rb:429:in `eval'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/3.2.0/erb.rb:429:in `result'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/actions/file_manipulation.rb:131:in `block in template'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/actions/create_file.rb:53:in `render'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/actions/create_file.rb:63:in `block (2 levels) in invoke!'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/actions/create_file.rb:63:in `open'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/actions/create_file.rb:63:in `block in invoke!'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/actions/empty_directory.rb:117:in `invoke_with_conflict_check'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/actions/create_file.rb:60:in `invoke!'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/actions.rb:93:in `action'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/actions/create_file.rb:25:in `create_file'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/actions/file_manipulation.rb:122:in `template'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4.3/lib/rails/generators/named_base.rb:25:in `block in template'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4.3/lib/rails/generators/named_base.rb:45:in `inside_template'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4.3/lib/rails/generators/named_base.rb:24:in `template'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/administrate-0.19.0/lib/generators/administrate/dashboard/dashboard_generator.rb:40:in `create_dashboard_definition'

If I try to run it again, I get a different error:

/Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/callbacks.rb:25:in `on_file_autoloaded': expected file /Users/youngcha/reykitestapp/app/dashboards/read_only_dashboard_dashboard.rb to define constant ReadOnlyDashboardDashboard, but didn't (Zeitwerk::NameError)

      raise Zeitwerk::NameError.new(msg, cref.last)
      ^^^^^
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:31:in `require'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/helpers.rb:135:in `const_get'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/helpers.rb:135:in `cget'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/eager_load.rb:169:in `block in actual_eager_load_dir'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/helpers.rb:40:in `block in ls'
	from /Users/youngcha/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/loader/helpers.rb:25:in `each'

I cannot appear to uninstall administrate either by calling "rails d administrate:install". How do I get past these errors? I tried renaming my controller back to the original name, but the error persists no matter what I do.

@ycha28 ycha28 added the bug breakages in functionality that is implemented label Aug 7, 2023
@pablobm
Copy link
Collaborator

pablobm commented Oct 13, 2023

Sorry it took so long to come back to you. Are you still having this issue? What is the name of the model you refer to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug breakages in functionality that is implemented
Projects
None yet
Development

No branches or pull requests

2 participants