Assuming I have a directory structure similar to:
path_to_file/one/index.html
How can I set my sinatra app to be routed to
mysite.com/path_to_file/one/
and have the previously mentioned file to render? path_to_file will always stay the same, but there will be different folders (two, three, etc.) inside it.
I’ve tried the following:
get '/path_to_file/:number' do
File.read(File.join('path_to_file', "#{params[:number]}", "index.html"))
end
but then the e.g. javascript file linked from index.html doesn’t render correctly.
Got it!
Order is important, since if these two methods are reversed,
get '/path_to_file/:number'becomes a superset ofget '/path_to_file/:number/:file'.