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

Generator not respecting abstract_class #581

Closed
lukeredpath opened this issue May 16, 2016 · 2 comments
Closed

Generator not respecting abstract_class #581

lukeredpath opened this issue May 16, 2016 · 2 comments

Comments

@lukeredpath
Copy link

lukeredpath commented May 16, 2016

I'm trying to set up Administrate with a new Rails 5 project, using the as yet unmerged compatibility branch.

The administrate:install generator fails with the error:

WARNING: Unable to generate a dashboard for ApplicationRecord.
         It is not connected to a database table.
         Make sure your database migrations are up to date.
      create  app/controllers/admin/application_controller.rb
      create  app/dashboards/_dashboard.rb
/Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc1/lib/rails/generators/named_base.rb:102:in `map!': undefined method `camelize' for nil:NilClass (NoMethodError)

Its possible this isn't a Rails 5 compatibility issue but something that has surfaced due to Rails including ApplicationRecord, an abstract sub-class of ActiveRecord::Base, by default.

Also mentioned on #575

Not sure if this is related, but I also ended up with an empty "_dashboard.rb" file. After looking at the generator code I notice that if I run Administrate::Namespace.new(:admin).resources on the console it returns [:""].

@lukeredpath
Copy link
Author

On further inspection I think there's two issues here: the warning generated (which is just a warning so its not the reason the generator is failing) and the attempt to try and generate dashboards crashing with the error above.

Here's the full backtrace to the first line of administrate code:

     create  app/dashboards/_dashboard.rb
/Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc1/lib/rails/generators/named_base.rb:102:in `map!': undefined method `camelize' for nil:NilClass (NoMethodError)
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc1/lib/rails/generators/named_base.rb:102:in `class_name'
    from (erb):3:in `template'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/2.2.0/erb.rb:863:in `eval'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/2.2.0/erb.rb:863:in `result'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `call'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `render'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block (2 levels) in invoke!'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `open'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block in invoke!'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `call'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `invoke_with_conflict_check'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:25:in `create_file'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:115:in `template'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc1/lib/rails/generators/named_base.rb:26:in `block in template'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc1/lib/rails/generators/named_base.rb:60:in `inside_template'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc1/lib/rails/generators/named_base.rb:25:in `template'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/administrate-37e72b8e785d/lib/generators/administrate/dashboard/dashboard_generator.rb:30:in `create_dashboard_definition'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc1/lib/rails/generators.rb:180:in `invoke'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/administrate-37e72b8e785d/lib/administrate/generator_helpers.rb:4:in `call_generator'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/administrate-37e72b8e785d/lib/generators/administrate/install/install_generator.rb:27:in `block in run_dashboard_generators'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/administrate-37e72b8e785d/lib/generators/administrate/install/install_generator.rb:26:in `each'
    from /Users/luke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/administrate-37e72b8e785d/lib/generators/administrate/install/install_generator.rb:26:in `run_dashboard_generators'

@nickcharlton
Copy link
Member

It seems like we solved this one elsewhere, so I'm going to close it. If that's not the case, please open another issue!

nickcharlton added a commit that referenced this issue Jul 12, 2019
In investigating #581, we released the `ApplicationRecord` change
introduced in Rails 5 did not happen in our `example_app` models.
nickcharlton added a commit that referenced this issue Aug 16, 2019
In investigating #581, we released the `ApplicationRecord` change
introduced in Rails 5 did not happen in our `example_app` models.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants