在heroku上运行rails应用程序,在/public文件夹中看不到静态页面 [英] running rails app on heroku, can't see static pages in /public folder

查看:27
本文介绍了在heroku上运行rails应用程序,在/public文件夹中看不到静态页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个静态页面,在本地运行时作为 localhost:3000/foo.html 工作,但是一旦上传到 heroku 就不起作用了.

I have a couple static pages which when running locally work as localhost:3000/foo.html, but this doesn't work once uploaded to heroku.

我尝试将以下内容添加到 routes.rb 文件:

I tried adding the following to the routes.rb file:

match '/foo', :to => redirect('/public/foo.html')

但这似乎不起作用,它将我重定向到 foobar.com/public/foo.html,但仍然找不到任何内容.

but that doesn't seem to work, it redirects me to foobar.com/public/foo.html, but still finds nothing there.

推荐答案

Per 这篇文章,你需要告诉 Rails 自己提供静态资源:

Per this article, you will need to tell Rails to serve static assets itself with:

config.serve_static_assets = true

在你的 config/environments/production.rb

这篇关于在heroku上运行rails应用程序,在/public文件夹中看不到静态页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆