在heroku上运行rails应用程序,无法在/ public文件夹中看到静态页面 [英] running rails app on heroku, can't see static pages in /public folder
本文介绍了在heroku上运行rails应用程序,无法在/ public文件夹中看到静态页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有几个静态页面,在本地运行时以localhost:3000 / foo.html的形式运行,但是一旦上传到heroku,这个页面就无法运行。
I尝试将以下内容添加到routes.rb文件中:
匹配'/ foo',:to => redirect('/ public / foo.html')
但这似乎不起作用,它将我重定向到foobar.com/public/foo.html,但仍然没有发现任何内容。
config.serve_static_assets = true
存放在 config / environments / production.rb中
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.
I tried adding the following to the routes.rb file:
match '/foo', :to => redirect('/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 this article, you will need to tell Rails to serve static assets itself with:
config.serve_static_assets = true
in your config/environments/production.rb
这篇关于在heroku上运行rails应用程序,无法在/ public文件夹中看到静态页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文