firstdraft / draft_generators

Rails generators that help beginners learn to program.
MIT License
2 stars 3 forks source link

Trouble Generating ActiveAdmin in Rails 6 #68

Closed jelaniwoods closed 5 years ago

jelaniwoods commented 5 years ago

After a basic rails new that generates a full Rails 6 app, I added activeadmin, devise and draft_generators then bundled.

I entered:

$ rails generate draft:resource movie title:string year:integer duration:integer description:text image:string director_id:integer

This was the result. It seems to fail doing something with active admin guessing from this line:

draft_generators-5f55458698c2/lib/generators/draft/model/model_generator.rb:15:in `generate_active_admin'
Running via Spring preloader in process 10461
/home/sun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:199: warning: Insecure world writable dir /home/sun/.rvm/gems/ruby-2.6.3/bin in PATH, mode 040777
      create  app/controllers/movies_controller.rb
      invoke  active_record
      create    db/migrate/20190926152555_create_movies.rb
      create    app/models/movie.rb                                                                                           invoke    test_unit
      create      test/models/movie_test.rb                                                                                   create      test/fixtures/movies.yml
Traceback (most recent call last):
        80: from -e:1:in `<main>'
        79: from /home/sun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'            78: from /home/sun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'            77: from /home/sun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application/boot.rb:19:in `<top (required)>'
        76: from /home/sun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:139:in `run'
        75: from /home/sun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:139:in `loop'
        74: from /home/sun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:145:in `block in run'               73: from /home/sun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:175:in `serve'
        72: from /home/sun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:175:in `fork'
        71: from /home/sun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:215:in `block in serve'             70: from /home/sun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/command_wrapper.rb:38:in `call'
        69: from /home/sun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/commands/rails.rb:6:in `call'
        68: from /home/sun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
        67: from /home/sun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
        66: from /mnt/c/Users/jelan/workspace/my_stuff/test-draft-gen/bin/rails:9:in `<main>'
        65: from /home/sun/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.1.10/lib/zeitwerk/kernel.rb:23:in `require'
        64: from /home/sun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        63: from /home/sun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        62: from /home/sun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        61: from /home/sun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        60: from /home/sun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        59: from /home/sun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/commands.rb:18:in `<main>'
        58: from /home/sun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/command.rb:46:in `invoke'
        57: from /home/sun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/command/base.rb:65:in `perform'
        56: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        55: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        54: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        53: from /home/sun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/commands/generate/generate_command.rb:26:in `perform'
        52: from /home/sun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/generators.rb:276:in `invoke'
        51: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
        50: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/group.rb:232:in `dispatch'
        49: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `invoke_all'
        48: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `map'
        47: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `each'
        46: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `block in invoke_all'            45: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        44: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        43: from /home/sun/.rvm/gems/ruby-2.6.3/bundler/gems/draft_generators-5f55458698c2/lib/generators/draft/resource/resource_generator.rb:29:in `generate_model'
        42: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:115:in `invoke'
        41: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/group.rb:232:in `dispatch'
        40: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `invoke_all'
        39: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `map'
        38: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `each'
        37: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `block in invoke_all'            36: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        35: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        34: from /home/sun/.rvm/gems/ruby-2.6.3/bundler/gems/draft_generators-5f55458698c2/lib/generators/draft/model/model_generator.rb:15:in `generate_active_admin'
        33: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:115:in `invoke'
        32: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/group.rb:232:in `dispatch'
        31: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `invoke_all'
        30: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `map'
        29: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `each'
        28: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `block in invoke_all'            27: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        26: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        25: from /home/sun/.rvm/gems/ruby-2.6.3/gems/activeadmin-2.3.1/lib/generators/active_admin/resource/resource_generator.rb:15:in `generate_config_file'
        24: from /home/sun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/generators/named_base.rb:24:in `template'         23: from /home/sun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/generators/named_base.rb:45:in `inside_template'
        22: from /home/sun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/generators/named_base.rb:25:in `block in template'
        21: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/actions/file_manipulation.rb:122:in `template'        20: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/actions/create_file.rb:25:in `create_file'            19: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/actions.rb:94:in `action'
        18: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/actions/create_file.rb:60:in `invoke!'                17: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/actions/empty_directory.rb:117:in `invoke_with_conflict_check'
        16: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/actions/create_file.rb:63:in `block in invoke!'
        15: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/actions/create_file.rb:63:in `open'
        14: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/actions/create_file.rb:63:in `block (2 levels) in invoke!'
        13: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/actions/create_file.rb:53:in `render'
        12: from /home/sun/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/actions/file_manipulation.rb:131:in `block in template'
        11: from /home/sun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/erb.rb:901:in `result'
        10: from /home/sun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/erb.rb:901:in `eval'
         9: from /home/sun/.rvm/gems/ruby-2.6.3/gems/activeadmin-2.3.1/lib/generators/active_admin/resource/templates/admin.rb.erb:8:in `template'
         8: from /home/sun/.rvm/gems/ruby-2.6.3/gems/activeadmin-2.3.1/lib/active_admin/generators/boilerplate.rb:17:in `permit_params'
         7: from /home/sun/.rvm/gems/ruby-2.6.3/gems/activeadmin-2.3.1/lib/active_admin/generators/boilerplate.rb:13:in `assignable_attributes'
         6: from /home/sun/.rvm/gems/ruby-2.6.3/gems/activeadmin-2.3.1/lib/active_admin/generators/boilerplate.rb:9:in `attributes'
         5: from /home/sun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/core_ext/string/inflections.rb:68:in `constantize'
         4: from /home/sun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/inflector/methods.rb:280:in `constantize'
         3: from /home/sun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/inflector/methods.rb:280:in `inject'
         2: from /home/sun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/inflector/methods.rb:280:in `each'
         1: from /home/sun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/inflector/methods.rb:282:in `block in constantize'
/home/sun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/inflector/methods.rb:282:in `const_get': uninitialized constant Movie (NameError)                                                                       

The admin/movies.rb file has been created but is empty. What changed in Rails 6 or activeadmin and how do we make this backwards compatible?

jelaniwoods commented 5 years ago

This is an issue because of the latest version of activeadmin (2.4.0) I guess, requires a table to be created before you can generate a resource. Temporary fix is to enforce version 2.2.0 in all projects.