Leem.fin
Leem.fin

Reputation: 42622

Rails : Why my first page does not show? (routing error)

I use scaffold to create my first MVC in Rails 3.1

rails generate scaffold Post name:string title:string content:text

I deleted the public/index.html file

Then I added following code in config/routes.rb

root :to => 'post#index'

But when I start the server with rails s, there is an error:

ActionController::RoutingError (uninitialized constant PostController):

Why? why it does not render the posts/index.html.erb but throw the error?

Upvotes: 0

Views: 287

Answers (2)

Chris Ledet
Chris Ledet

Reputation: 11628

It created PostsController, not PostController. It's plural.

Change your routes.rb file to this: root :to => 'posts#index'

EDIT: I didn't see the OP's comment.

Upvotes: 2

Lester Peabody
Lester Peabody

Reputation: 1888

Did you run rake db:migrate first?

Upvotes: 0

Related Questions