I have been following a tutorial @ Noupe with the intention of learning Rails. It’s going well and the app works, but I gather it was written for Rails 2, so there are some deprecated pieces of code used.
While I have resolved most of these, I have one remaining problem with the routing. The Rails 2 code in the tutorial is:
ActionController::Routing::Routes.draw do |map|
map.resources :posts
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
This works fine, but it is the old code. I have attempted to rewrite the code as follows:
Twitter::Application.routes do
resources :posts
match ':controller/:action/:id'
match ':controller/:action/:id.:format'
end
This results in an error when I attempt to visit http://localhost:3000/posts –
Routing Error
No route matches “/posts”
Can anyone suggest where I am going wrong? I did notice that I get a compiler error if I write twitter in the first line (instead of Twitter) – since my app is named twitter, I thought this might be the issue, but it does not seem to be.
Any help greatly appreciated!
It seems like you are missing the call to the method draw. Try to change the first line to the following: