Dynamic index.html [Rails 4 Countdown to 2013]

Posted on

This post is part of a series of 31 Rails 4 articles being released each day in December 2012.

When you start a new Rails application and run the server, the first thing you see is the famous Welcome aboard page. This index.html page is served directly from your Rails application's public directory. Serving a file from the public directory means that it will always take precedence over any dynamic route in your application.

In Rails 4 the static index.html file has been removed from the public directory and the functionality has been moved to a dynamic route instead. This means that you no longer have to delete public/index.html every time you start a new Rails application.

Behind the scenes

A new Rails internal controller Rails::WelcomeController has been introduced to serve the dynamic welcome screen. If your application does not have a root route defined in routes.rb, it will render the rails/welcome#index action instead.

Further Reading


This post is by Rida Al Barazi. Rida is a passionate web developer experienced in building web applications for startups. He started working with Rails in 2005, co-authored Beginning Rails 3, and has spoken at conferences around the world.


comments powered by Disqus