开发者

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开发者_JS百科 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?


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.


Did you run rake db:migrate first?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜