开发者

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

开发者 https://www.devze.com 2023-04-13 07:45 出处:网络
I use scaffold to create my first MVC in Rails 3.1 rails generate scaffold Post name:string title:string content:text

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

精彩评论

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