4

I have a rails application with static content in the public directory (e.g. public/index.html) and additional static content in nested subdirectories (e.g. public/one/two/index.html).

All the static content is served correctly if I run it locally via script/server but when I upload it to Heroku the top-level page loads correctly but the nested content returns a 404.

I've found a number of resources (for example this question) which discuss static content in rails but they all seem to assume a fairly simple structure with a single directory containing all the files.

Is there any way I can fix this?

Community
  • 1
  • 1
Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
  • Are you saying it doesn't load when you go to `/one/two/index.html`, or is the problem that it isn't served as `/one/two`? – mckeed Apr 21 '10 at 21:16
  • If you pushed it successfully to heroku and your directories had correct permission and there is nothing fishy in routes.rb I guess it should work properly.... – Gabriel Ščerbák Apr 22 '10 at 13:03
  • @mckeed - it isn't served as either `/one/two`, `/one/two/` or `/one/two/index.html`... – Matthew Murdoch Apr 22 '10 at 15:12
  • That's weird. Are images in public/images being served correctly? – mckeed Apr 22 '10 at 15:17
  • @mckeed - I believe so but am unable to check anymore as I've gone for a simpler approach using Sinatra rather than Rails and have managed to get it to work. – Matthew Murdoch Apr 23 '10 at 08:11

2 Answers2

1

If you have a very simple web application (with mostly static content, say) then using Sinatra on Heroku is much simpler to set up and prevents this type of problem.

Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
1

You can serve up static content on Heroku without writing any "code" at all... you just need to tell the "Rack" middleware where the content is (as detailed in this help article):

http://devcenter.heroku.com/articles/static-sites-on-heroku

GroovyCakes
  • 361
  • 2
  • 12