I am trying to add a "Back" tab to get back to resque-web. Following the steps in PLUGINS.md I came up with this code in lib/resque_web/engine.rb:
module ResqueWeb
module Plugins
module CustomTabs
class Engine < ::Rails::Engine
isolate_namespace ResqueWeb::Plugins::CustomTabs
end
def self.engine_path
'/back'
end
def self.tabs
[
{
'back' => Rails.application.routes.url_helpers.root_path,
}
]
end
end
end
end
But when I start the app I get the error:
/home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/route_set.rb:588:in `add_route': Invalid route name, already in use: 'root' (ArgumentError)
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
https://guides.rubyonrails.org/routing.html#restricting-the-routes-created
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/mapper.rb:1962:in `add_route'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/mapper.rb:1933:in `decomposed_match'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/mapper.rb:1897:in `block in map_match'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/mapper.rb:1891:in `each'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/mapper.rb:1891:in `map_match'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/mapper.rb:1639:in `match'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/mapper.rb:1967:in `match_root_route'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/mapper.rb:1672:in `root'
from /home/sergioro/learning/software/rails/webguardco.com/config/routes.rb:2:in `block in <top (required)>'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/route_set.rb:428:in `instance_exec'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/route_set.rb:428:in `eval_block'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/actionpack-7.0.4.3/lib/action_dispatch/routing/route_set.rb:410:in `draw'
from /home/sergioro/learning/software/rails/webguardco.com/config/routes.rb:1:in `<top (required)>'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/dead_end-4.0.0/lib/dead_end/core_ext.rb:65:in `load'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/dead_end-4.0.0/lib/dead_end/core_ext.rb:65:in `load'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/application/routes_reloader.rb:50:in `block in load_paths'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/application/routes_reloader.rb:50:in `each'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/application/routes_reloader.rb:50:in `load_paths'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/application/routes_reloader.rb:24:in `reload!'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/application/routes_reloader.rb:38:in `block in updater'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/activesupport-7.0.4.3/lib/active_support/file_update_checker.rb:83:in `execute'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/application/routes_reloader.rb:13:in `execute'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/application/finisher.rb:158:in `block in <module:Finisher>'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/initializable.rb:32:in `instance_exec'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/initializable.rb:32:in `run'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/initializable.rb:61:in `block in run_initializers'
from /home/sergioro/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
from /home/sergioro/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /home/sergioro/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /home/sergioro/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /home/sergioro/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:347:in `each'
from /home/sergioro/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:347:in `call'
from /home/sergioro/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
from /home/sergioro/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
from /home/sergioro/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/initializable.rb:60:in `run_initializers'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/application.rb:372:in `initialize!'
from /home/sergioro/learning/software/rails/webguardco.com/config/environment.rb:5:in `<top (required)>'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/dead_end-4.0.0/lib/dead_end/core_ext.rb:82:in `require'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/dead_end-4.0.0/lib/dead_end/core_ext.rb:82:in `require_relative'
from config.ru:3:in `block in <main>'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/rack-2.2.7/lib/rack/builder.rb:116:in `eval'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/rack-2.2.7/lib/rack/builder.rb:116:in `new_from_string'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/rack-2.2.7/lib/rack/builder.rb:105:in `load_file'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/rack-2.2.7/lib/rack/builder.rb:66:in `parse_file'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/rack-2.2.7/lib/rack/server.rb:349:in `build_app_and_options_from_config'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/rack-2.2.7/lib/rack/server.rb:249:in `app'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/rack-2.2.7/lib/rack/server.rb:422:in `wrapped_app'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/commands/server/server_command.rb:76:in `log_to_stdout'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/commands/server/server_command.rb:36:in `start'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/commands/server/server_command.rb:143:in `block in perform'
from <internal:kernel>:90:in `tap'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/commands/server/server_command.rb:134:in `perform'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/command/base.rb:87:in `perform'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/command.rb:48:in `invoke'
from /home/sergioro/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4.3/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I am trying to add a "Back" tab to get back to resque-web. Following the steps in PLUGINS.md I came up with this code in
lib/resque_web/engine.rb
:But when I start the app I get the error:
How could I fix this problem?