How to Change the Root Route from routes.rb in Rails 3

Tadashi Shigeoka ·  Sun, September 18, 2011

I looked up how to change the root route from routes.rb in Rails 3, so here’s a memo.

■ root

The route for the web application’s root ”/” uses the root directive in Rails 3.

For example, to make the show action of homeController the root, write the following in config/routes.rb:

root :to => 'home#show'

This alone will still show the default page, so rename or delete public/index.html to display any page at the root.

$ rm public/index.html

By the way, Rails 3 routes are detailed in the following article:

Rails 3のroutesまとめ (Rails 3 Routes Summary)

That’s all.

【Reference】

rails2.0でデフォルトのrouteを変更する方法 - Cafe L@ Bebop (How to change the default route in rails 2.0 - Cafe L@ Bebop)

That’s all from the Gemba.