【发布时间】:2011-04-30 03:50:58
【问题描述】:
假设我的目录结构类似于:
path_to_file/one/index.html
如何将我的 sinatra 应用设置为路由到
mysite.com/path_to_file/one/
并且有前面提到的文件要渲染吗? path_to_file 将始终保持不变,但其中会有不同的文件夹(two、three 等)。
我尝试了以下方法:
get '/path_to_file/:number' do
File.read(File.join('path_to_file', "#{params[:number]}", "index.html"))
end
但是然后例如从 index.html 链接的 javascript 文件无法正确呈现。
【问题讨论】:
-
你的 Sinatra 控制器是什么样子的?
-
不知道你的意思...不是我的 Sinatra 控制器上面的代码吗?
标签: ruby sinatra static-files