Richard77
Richard77

Reputation: 21621

RoR: Displaying index page using "root" in routing file?

This is my very first app that I'm running in RoR. This is the template app/views/home/index.html.erb. It contains this

<h1>Hello, World!</h1>

My controller is app/controllers/home_controllers.rb. But the class inside the file is Home

Home < ActionController::Base
   def index
   end
end

Finally, here is my routing file

Blog::Application.routes.draw do
   root :to => 'Home#index'
end

When I am running this application, I'm getting the following error: "Routing Error: No route matches [GET] "/""

What's wrong with my application?

EDIT

After applying all the corrections, this is how it looks.

HomeController < ActionController:: Base
   def index
   end
end

And the routing is now

Blog::Application.routes.draw do
   root :to => 'Home#index'
end

I've also restarted the server, but I'm still getting the same error.

Thanks for helping

Upvotes: 0

Views: 66

Answers (3)

Aaron McIver
Aaron McIver

Reputation: 24713

Get rid of the pluralization, home_controllers should be home_controller. In addition name your class HomeController instead of Home.

Upvotes: 1

Salil
Salil

Reputation: 47482

Try

   root :to => 'home#index'

Upvotes: 1

Benjamin Tan Wei Hao
Benjamin Tan Wei Hao

Reputation: 9691

It should be HomeController instead of Home.

Upvotes: 1

Related Questions