【问题标题】:In RoR how can I set the default file DirectoryIndex?在 RoR 中如何设置默认文件 DirectoryIndex?
【发布时间】:2012-01-09 17:44:43
【问题描述】:

在 Apache 中,我可以使用 DirectoryIndex 指定不同的文件或扩展名作为默认服务 - 我如何使用 RoR 完成此操作?在公共目录中,我有一些文件夹需要将 JS 文件作为索引。

使用 Apache,我会这样做:

DirectoryIndex index.js

我在本地使用 WEBrick 和 Heroku 进行生产。

【问题讨论】:

    标签: ruby-on-rails ruby heroku webrick


    【解决方案1】:

    除非你使用像rack_rewrite这样的东西,否则你不能用Heroku真正做到这一点

    【讨论】:

    • +1 获取有关 rack_rewrite 启发我的信息——总有一天会派上用场
    【解决方案2】:

    我最终创建了一个加载到 JS 中的控制器,例如

    def show
      output = File.read("public/js/stats/index.js")
      render :text => output
    end
    

    然后我创建了一条路线

    match 'stats/index' => 'stats#show'
    

    可能不是最优雅的,但我认为它比管理本地和生产环境之间的依赖关系更容易

    【讨论】:

      猜你喜欢
      • 2019-06-23
      • 2013-11-05
      • 2020-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-29
      相关资源
      最近更新 更多