Rails 访问 Rails 服务根路径时如何指向 public 下文件,可以实现吗?

zhangxiaoshang · August 29, 2017 · Last by msg7086 replied at August 31, 2017 · 2098 hits

启动 rails 服务后访问 localhost:3000,这时默认请求的是 public/index.html。

我想在请求 localhost:3000 时请求的是 public/mydir/index.html 如何实现?

1 Floor has deleted

通过修改 routes.rb 指定路由应该可以实现。但是为什么要这样做?新建一个 static_controller 不是更简单和可定制吗?

Nginx location 配置!

Reply to huacnlee

Nginx 什么的不熟悉,使用 index.html 做中转了

Reply to springwq

使用 index.html 中转实现了

那就学一下呗。毕竟你 Rails 最终上线还是要走 Nginx 之类的做前端的。

You need to Sign in before reply, if you don't have an account, please Sign up first.