0

I'am working on sixrevision.com tutorial “How to Create a Blog from Scratch Using Ruby on Rails” . I try to convert It from rails 2.x to 3.x. When I run localhost:3000 I get this:

Routing Error

uninitialized constant PostController

Try running rake routes for more information on available routes.

Rake Routes shows me this:

    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 file:

    Myblog::Application.routes.draw do

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

    end

Anybody got any idea? Thanks for intrest & help!

szatan
  • 517
  • 4
  • 8
  • 26

2 Answers2

2

In routes.rb file:

resources :posts do
  resources :comments
end
Eru
  • 675
  • 4
  • 8
0

In your routes.rb you should have:

root :to => 'posts#index'

because you do not have (probably) PostController but PostsController

sebast26
  • 1,732
  • 1
  • 22
  • 38