Ruby on rails 教程应用程序从rails 2.x转换为3.x时出现路由错误

Ruby on rails 教程应用程序从rails 2.x转换为3.x时出现路由错误,ruby-on-rails,ruby-on-rails-3,ruby-on-rails-2,Ruby On Rails,Ruby On Rails 3,Ruby On Rails 2,我正在编写sixrevision.com教程“如何使用RubyonRails从头开始创建博客”。我尝试将它从Rails2.x转换为3.x。当我运行localhost:3000时,我得到: Routing Error uninitialized constant PostController Try running rake routes for more information on available routes. Rake Routes向我展示了这一点: posts GET

我正在编写sixrevision.com教程“如何使用RubyonRails从头开始创建博客”。我尝试将它从Rails2.x转换为3.x。当我运行localhost:3000时,我得到:

Routing Error

uninitialized constant PostController

Try running rake routes for more information on available routes.
Rake Routes向我展示了这一点:

    posts GET  /posts(.:format)               posts#index {:has_many=>:comments}
          POST /posts(.:format)               posts#create {:has_many=>:comments}
 new_post GET  /posts/new(.:format)           posts#new {:has_many=>:comments}
edit_post GET  /posts/:id/edit(.:format)      posts#edit {:has_many=>:comments}
     post GET  /posts/:id(.:format)           posts#show {:has_many=>:comments}
          PUT  /posts/:id(.:format)           posts#update {:has_many=>:comments}
       DELETE  /posts/:id(.:format)           posts#destroy {:has_many=>:comments}
               /:controller/:action/:id(.:format) :controller#:action
               /:controller/:action/:id.:format   :controller#:action
   root        /                                  post#index
My routes.rb文件:

    Myblog::Application.routes.draw do

       resources :posts, :has_many => :comments
       match ':controller/:action/:id'
       match ':controller/:action/:id.:format'
       root :to => "post#index"

    end

有人知道吗?谢谢你的关心和帮助

在routes.rb中,您应该有:

root :to => 'posts#index'

因为您在
routes.rb
文件中没有(可能)PostController,只有PostsController

resources :posts do
  resources :comments
end