From b0caea29c2da9f4c8bb958019813482da297067d Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 18 Jul 2013 21:27:14 -0500 Subject: Match Dev/Prod parity for Index Page With Rails 4 the default index page was moved from a static file `index.html` inside the `public/` folder to an internal controller/view inside of the railties gem. This was to allow use of erb in the default index page and to remove the requirement that new apps must delete a static file to make their index pages work. While this was a good change, the functionality was unexpected to developers who wish to get their apps running in production ASAP. They will create a new app `rails new my app`, start a server to verify it works, then immediately deploy the app to verify that it can start working in production. Unfortunately locally they see a page when they visit `localhost:3000` when they visit their production app they get an error page. We initially anticipated this problem in the original pull request, but did not properly anticipate the severity or quantity of people who would like this functionality. Having a default index page serves as an excellent litmus test for a passed deploy on default apps, and it is very unexpected to have a page work locally, but not on production. This change makes the default index page available in production if the developer has not over-written it by defining their own `root` path inside of routes. --- railties/lib/rails/application/finisher.rb | 4 +++- railties/lib/rails/templates/rails/welcome/index.html.erb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index 7a1bb1e25c..1e4c6ca921 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -25,9 +25,11 @@ module Rails get '/rails/info/properties' => "rails/info#properties" get '/rails/info/routes' => "rails/info#routes" get '/rails/info' => "rails/info#index" - get '/' => "rails/welcome#index" end end + app.routes.append do + get '/' => "rails/welcome#index" + end end initializer :build_middleware_stack do diff --git a/railties/lib/rails/templates/rails/welcome/index.html.erb b/railties/lib/rails/templates/rails/welcome/index.html.erb index 4c4c80ecda..bef5d03ca0 100644 --- a/railties/lib/rails/templates/rails/welcome/index.html.erb +++ b/railties/lib/rails/templates/rails/welcome/index.html.erb @@ -227,7 +227,7 @@
  • Set up a root route to replace this page

    -

    You're seeing this page because you're running in development mode and you haven't set a root route yet.

    +

    You're seeing this page because you haven't set a root route yet.

    Routes are set up in config/routes.rb.

  • -- cgit v1.2.3