Where is the default Welcome aboard page in my application?

I looked through my application directories and I cannot find the html page for the welcome page on the default page. I also cannot find the route for the default welcome page in routes.rb. How does my rails application route http://localhost:3000/ to a non-existent page in my application?

The rails server creates this information:

 Started GET "/" for 127.0.0.1 at 2013-07-31 02:00:13 -0600 Processing by Rails::WelcomeController#index as HTML Rendered /Users/7stud/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/templates/rails/welcome/index.html.erb (0.1ms) Completed 200 OK in 3ms (Views: 2.5ms | ActiveRecord: 0.0ms) 

So, it seems to me that there is a controller buried in a gem somewhere processing the request.

+42
ruby-on-rails ruby-on-rails-4
Jul 31 '13 at 8:03
source share
1 answer

With Rails 4, the Welcome Aboard page is no longer in public/index.html . This, as you already discovered, is inside one of the Rails stones.

So, you yourself have answered the question; Welcome on board page - in your case - is located at /Users/7stud/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/templates/rails/welcome/index.html.erb

To get rid of it, follow the instructions on the page. Mainly:

  • Create controller
  • Add the root route to config/routes.rb to route to this newly created controller.

As for how the request to your application ends on the controller inside the rails, let’s insert into the gem: Inside Rails::Application::Finisher we find this:

 initializer :add_builtin_route do |app| if Rails.env.development? app.routes.append do 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 end 

This block adds several routes to your application when working in development mode - one of them is the route to the "Welcome aboard" action: get '/' => "rails/welcome#index"

This - like any other initializer - runs when your application server starts ( rails server runs, or how you do it). In the case of Finisher its entire initializer starts after all other initializers are started.

Notice how routes are added so that they are displayed last in Routeset. This, combined with the fact that Rails uses the first comparable route it finds, ensures that these default routes will only be used if no other route is defined.

+52
Jul 31 '13 at 8:19
source share



All Articles