0

私は sixrevision.com のチュートリアル「Ruby on Rails を使用してゼロからブログを作成する方法」に取り組んでいます。Rails 2.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

私の 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

誰かが何か考えましたか?興味と助けをありがとう!

4

2 に答える 2

2

ファイルroutes.rb内:

resources :posts do
  resources :comments
end
于 2013-02-12T23:28:49.357 に答える
0

あなたのroutes.rbには次のものが必要です:

root :to => 'posts#index'

あなたは(おそらく)PostControllerではなくPostsControllerを持っているからです

于 2013-02-12T23:27:43.890 に答える