Best practice for root?

Good morning,

I just started a new application and was wondering what the best
practice for root (-> http://localhost:3000/) is. My landing page is
going to load data from 5 different models and I don't really know if I
should put a "welcome" action in one of these 5 controllers or create
something like a home/welcome controller.

Any suggestions, opinions are highly appreciated.

Thank you

Hi Heinz,

I usually create a controller home with an index action for this purpose, and I guess this is what the majority of Rails developers do. When I began developing in Rails I have also experienced this dilemma, but then I found this model in the majority of the books I have read.

Hope this helps you get started.

Best Regards,


Yes it does, thanks Fidel!

Hi Hanz,

Also don't forget to create a route in your routes.rb file. In Rails 3, you map it like this:

root :to => "home#index"

In prior versions you do it like this:

map.root :controller => "home", :action => "index"

This will load your default controller with its respective action whenever you type http://localhost:3000 or http://yourdomainname.

And don't forget to remove the file public/index.html. If you don't remove it, you will continue seeing the Rails default home page.

Best Regards,


Working like a charm already, thanks a lot!