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?
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With