'Is the a way to nest routes when the routes are not defined properly ruby
I want to go down a deep repository where the routes are not defined properly. with the brute fix, I can go down 2 levels.
is there a way to get access to multiple parameters and go down n levels deep.
get '/' do
@command = Command.new
@processes, @error, @currentFilesAndFolders, @valueTest = nil, nil, @command.exec, "GithubIntegration"
# Render the view
erb :index
end
get '/:id' do
@command = Command.new
# using nested routing system.
# @processes, @error, @currentFilesAndFolders = @command.exec
@currentFilesAndFolders, @valueTest = @command.NextFilesAndFolders(params[:id]), params[:id]
# @currentFilesAndFolders = @command.NextFilesAndFolders("hi")
erb :index
end
get '/:level/:id' do
@command = Command.new
# using nested routing system.
# @processes, @error, @currentFilesAndFolders = @command.exec
@currentFilesAndFolders, @valueTest = @command.NextFilesAndFolders(params[:level]+"/"+params[:id]), params[:id]
# @currentFilesAndFolders = @command.NextFilesAndFolders("hi")
erb :index
end ```
Solution 1:[1]
Use route globbing
get "/*path/:id"
Where *path would match any number of segments:
/level1/level2/1will matchpathas/levle1/level2andidas1/1/2/3/4/9will matchpathas/1/2/3/4andidas9
https://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alex |
