0

I am making one static website a day for 30 days, and I want to create a small Rails app to showcase these websites. I will be hosting this on Heroku. When I run my Rails app locally it works, but it won't work on Heroku.

I read the thread about rendering static HTML pages and got it to work! By simply making links directly to my public folder:

views/landings/index.html.erb

<ul>
  <li>
  <a href="../oneWebsiteADay/colorNotes/index.html">Color Notes</a>
  </li>
  <li>
    <a href="../oneWebsiteADay/yeOldeMuffinShoppe/index.html">Ye Olde Muffin Shoppe</a>
  </li>
</ul>

This works, and I am able to click the links and view the static websites in their entirety. When I deploy to Heroku though I receive the following error:

Rails error

I have read all documentation Heroku provides about rendering static content with Rails and modified my configurations accordingly:

config/environments/production.rb

Rails.application.configure do
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = true
  config.serve_static_assets = true
  config.assets.js_compressor = :uglifier
  config.assets.compile = true
  config.assets.digest = true
  config.log_level = :info
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.log_formatter = ::Logger::Formatter.new
  config.active_record.dump_schema_after_migration = false
end

But I am still receiving the error. Not sure what else to do at this point How do I display static HTML pages on heroku?

Routes:

Rails.application.routes.draw do
  get "/", to: 'landings#index'
end
Community
  • 1
  • 1
chopper draw lion4
  • 12,401
  • 13
  • 53
  • 100

1 Answers1

0

There is no route in the routes file for your links, hence the error. In the link you posted it is telling you to define the route in your routes file using:

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

So if you define your route in the routes file to be:

get '/colorNotes', :to => redirect('/oneWebsiteADay/colorNotes/index.html')
get '/yeOldeMuffinShoppe', :to => redirect('/oneWebsiteADay/yeOldeMuffinShoppe/index.html')

And change the link tags accordingly:

<a href="/colorNotes">Color Notes</a>
<a href="/yeOldeMuffinShoppe">Ye Olde Muffin Shoppe</a>

I think this will work, but I couldn't figure out why it doesn't search the public folder on heroku.

Also, just fyi, I think all you need is:

config.serve_static_assets = true

Not all those other settings, for being able to reach the public directory anyway.

Community
  • 1
  • 1
trueinViso
  • 1,354
  • 3
  • 18
  • 30