Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running rails app on heroku, can't see static pages in /public folder

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.

like image 447
cbass Avatar asked Jul 11 '12 19:07

cbass


2 Answers

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

like image 98
Ryan Daigle Avatar answered Nov 16 '22 10:11

Ryan Daigle


Alternatively you can add the rails_12factor gem to the production group:

gem 'rails_12factor', group: :production

according to Heroku. This will also redirect log to stdout as also required by Heroku.

like image 39
Franklin Yu Avatar answered Nov 16 '22 08:11

Franklin Yu