Rails update to 5.2 error: The direct method can not be used inside a routes scope block

0

I'm trying to upload the Rails version from version 5.1.2 to version 5.2.2 and I'm having the following error when I try to upload the application server: The direct method can't be used inside a routes scope block (RuntimeError)

Here is the complete error log:

Exiting
Traceback (most recent call last):
        92: from bin/rails:3:in '<main>'
        91: from bin/rails:3:in 'load'
        90: from /Users/almirsantosfilho/Documents/GitHub/umanni_hr/bin/spring:15:in '<top (required)>'
        89: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:65:in 'require'
        88: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:65:in 'require'
        87: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in'<top (required)>'
        86: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in'load'
        85: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/bin/spring:49:in '<top (required)>'
        84: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client.rb:30:in 'run'
        83: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in 'call'
        82: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in 'call'
        81: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in 'load'
        80: from /Users/almirsantosfilho/Documents/GitHub/umanni_hr/bin/rails:9:in '<top (required)>'
        79: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in 'require'
        78: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in 'load_dependency'
        77: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in 'block in require'
        76: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in 'require'
        75: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in 'require_with_bootsnap_lfi'
        74: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in 'register'
        73: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in 'block in require_with_bootsnap_lfi'
        72: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in 'require'
        71: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/commands.rb:18:in '<main>'
        70: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/command.rb:46:in 'invoke'
        69: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/command/base.rb:65:in 'perform'
        68: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/thor-0.19.4/lib/thor.rb:369:in 'dispatch'
        67: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in 'invoke_command'
        66: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/thor-0.19.4/lib/thor/command.rb:27:in 'run'
        65: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142:in 'perform'
        64: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142:in 'tap'
        63: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:147:in 'block in perform'
        62: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:51:in 'start'
        61: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:89:in 'log_to_stdout'
        60: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/rack-2.0.6/lib/rack/server.rb:354:in 'wrapped_app'
        59: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:27:in 'app'
        58: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/rack-2.0.6/lib/rack/server.rb:219:in 'app'
        57: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/rack-2.0.6/lib/rack/server.rb:319:in 'build_app_and_options_from_config'
        56: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/rack-2.0.6/lib/rack/builder.rb:40:in 'parse_file'
        55: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in 'new_from_string'
        54: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in 'eval'
        53: from config.ru:in '<main>'
        52: from config.ru:in 'new'
        51: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in 'initialize'
        50: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in 'instance_eval'
        49: from config.ru:3:in 'block in <main>'
        48: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in 'require'
        47: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in 'load_dependency'
        46: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in 'block in require'
        45: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in 'require'
        44: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/skylight-core-3.1.2/lib/skylight/core/probes.rb:119:in 'require'
        43: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in 'require'
        42: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in 'require_with_bootsnap_lfi'
        41: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in 'register'
        40: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in 'block in require_with_bootsnap_lfi'
        39: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in 'require'
        38: from /Users/almirsantosfilho/Documents/GitHub/umanni_hr/config/environment.rb:5:in '<main>'
        37: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application.rb:361:in 'initialize!'
        36: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:60:in 'run_initializers'
        35: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:205:in 'tsort_each'
        34: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:226:in 'tsort_each'
        33: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:347:in 'each_strongly_connected_component'
        32: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:347:in 'call'
        31: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:347:in 'each'
        30: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:349:in 'block in each_strongly_connected_component'
        29: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:431:in 'each_strongly_connected_component_from'
        28: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:350:in 'block (2 levels) in each_strongly_connected_component'
        27: from /Users/almirsantosfilho/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:228:in 'block in tsort_each'
        26: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:61:in 'block in run_initializers'
        25: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in 'run'
        24: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in 'instance_exec'
        23: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/finisher.rb:130:in 'block in <module:Finisher>'
        22: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:10:in 'execute'
        21: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/file_update_checker.rb:83:in 'execute'
        20: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:30:in 'block in updater'
        19: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:20:in 'reload!'
        18: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in 'load_paths'
        17: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in 'each'
        16: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in 'block in load_paths'
        15: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in 'load'
        14: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in 'load_dependency'
        13: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in 'block in load'
        12: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/zeus-0.15.14/lib/zeus/load_tracking.rb:74:in 'load'
        11: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/zeus-0.15.14/lib/zeus/load_tracking.rb:82:in 'load'
        10: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in 'load'
         9: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in 'load'
         8: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activestorage-5.2.2/config/routes.rb:3:in '<main>'
         7: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:414:in 'draw'
         6: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:430:in 'eval_block'
         5: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:640:in 'with_default_scope'
         4: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:879:in 'scope'
         3: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:641:in 'block in with_default_scope'
         2: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:641:in 'instance_exec'
         1: from /Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/activestorage-5.2.2/config/routes.rb:6:in 'block in <main>'
/Users/almirsantosfilho/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:2099:in 'direct': The direct method can't be used inside a routes scope block (RuntimeError)
    
asked by anonymous 04.01.2019 / 20:41

2 answers

0

Almir Santos this may be some configuration problem of your old application, to run your application and find out where the problem is you can follow these steps below:

Note: Make sure you're using some version control system so you can compare the changes and keep everything that is required for your application to run.

  • Run the update rake :: task with the command:
    • rails app: update and allow the task to overwrite everything you request.
  • Check the changes and change only what is required.
    • If you are using git, you can run the git diff command.
  • Try to run the application with as few changes as possible to find exactly where the configuration problem is.
  • I think this can solve your problem. Let me know if you have a problem during this process.

        
    07.01.2019 / 14:29
    0

    You have a direct call in your config/routes.rb file that is not allowed because it is within namespace or scope .

    You are in documentation :

      

    NOTE: The direct method can not be used inside a scope block such as   namespace or scope and will raise an error if it detects that it is.

    To solve this, you can create a controller to route this, or take out scope or namespace .

        
    12.01.2019 / 11:56