sharls
sharls

Reputation: 89

Hello, Rails! No route matches [GET] "/"

Decided to try learning RoR. Got stuck in the very beginning of the Rails Guides.

Did everything exactly like in tutorial (except del public/index.html instead of rm public/index.html, since I have a windows) Checking localhost and getting:

No route matches [GET] "/"

Upvotes: 3

Views: 16746

Answers (3)

ddavison
ddavison

Reputation: 29032

Your site needs a root of some sort. If some index file does not exist in public/ (index.html|htm, default.html|htm, etc) then you need to tell your rails app where to go.

You can do this by editing your routes.rb (found in your config/ folder) and adding the line

root :to => 'somecontroller#index"

somecontroller represents the controller to use, and index represents the method that it should handle. typically index is preferred, which will render index.html.erb

You can find out more about routes by typing

rake routes

in your console.

Upvotes: 4

Nich
Nich

Reputation: 1102

I think you dont set a root path after you delete index.html?

maybe put your route

root :to => 'post#index' 

Upvotes: 0

Tilo
Tilo

Reputation: 33732

you should add:

 root :to => 'home#index'

see section 4.2 of the tutorial

The root route is the default route for your Rails application. You can point this to any controller and action you wish to display as the "main page".

root :to => "controller#action"

Upvotes: 1

Related Questions