Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 Static Public index.html

Sorry about the simple question, but I can't find the proper fix anywhere.

I used to have a Rails 3.x app running with a simple landing page on public/index.html. Of course, when I updated to Rails 4, my index page is no longer showing. Is there any way to get that feature back?

I know I can create a welcome#index controller/route and render the index.html as a response. But that goes to a different folder, without all the image and css assets that were on public, rendering the former static page.

Any tips?

like image 863
Gui Moura Avatar asked Jan 10 '14 21:01

Gui Moura


1 Answers

You need to use a controller, but can simply point it to your existing file.

e.g. in routes.rb

root :to => 'welcome#index'

And then in the Welcome controller:

def index
  render :file => 'public/index.html'
end

Alternatively, you could set up Apache to serve that file itself. Seems easier to let Rails do it though!

like image 66
Michael Martin Avatar answered Oct 04 '22 17:10

Michael Martin