views:

26

answers:

2

I'm runnng Rails 2.3.8.

I set up map.resources :users in my routes.rb file.

When I run rake routes it shows:

users GET /users(.:format)                   {:action=>"index", :controller=>"users"}
GET /users(.:format)                   {:action=>"index", :controller=>"users"}
new_user GET /users/new(.:format)               {:action=>"index", :controller=>"users"}
edit_user GET /users/:id/edit(.:format)          {:action=>"index", :controller=>"users"}
user GET /users/:id(.:format)               {:action=>"index", :controller=>"users"}
GET /users/:id(.:format)               {:action=>"index", :controller=>"users"}
GET /users/:id(.:format)               {:action=>"index", :controller=>"users"}
/:controller/:action/:id           
/:controller/:action/:id(.:format)

Sorry about the formatting. But the point is... 1) where are my "PUT", "POST", etc. routes?, 2) Why does everything point to index??

Any help would be much appreciated... Thanks!

UPDATE: Full routes file:

ActionController::Routing::Routes.draw do |map|
  map.login "login", :controller => "user_sessions", :action => "new"
  map.logout "logout", :controller => "user_sessions", :action => "destroy"

  map.resources :users

  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end

And my users_controller has all the usual new, create, show, edit, update methods...

A: 

OK. Can you tell what's in your user_controller first?

Daniel Chen
@Daniel Chen, you should use the comment for something like this.
Sam
My users controller has the usual new, create, update, edit, show methods.
Steven Ou
@Sam, thank you very for point it out. Now I'm aware of this. Thanks
Daniel Chen
A: 

I think you have one of two problems: either the output from rake routes has been mangled by your terminal screen, or your routes are being overridden by something else you installed, like a rails engine.

The first is easy to check for. it sounds like you have a basic user scaffold setup (and not much else) so fire up script/server, go to http://localhost:3000/users/new. If you see the new user page, you have a terminal display issue, but your routes are fine. If you see the users index page, however, proceed to the next step.

Double-check that the routes file you posted above is indeed the file for your app. This sounds ridiculous, but in some editors it's easy to open the wrong file. In TextMate for example, if you have some gems vendored and open the routes file via command-T, you can have multiple routes.rb files to choose from.

If you're sure you're viewing the correct routes file, the next step is to check your application for any other routes.rb files that may be overriding your main file. From terminal, you can run find ./ -name routes.rb and this will list any other routes files. This is especially likely if you have any rails engines installed.

Let me know how this goes - if you're still having problems, you can zip your application and e-mail it to me, and I'll take a look.

Jaime Bellmyer
sooo I figured out what is causing this problem. but I don't know why... it turns out that it's bundler! as soon as i take out the bundler code from boot.rb the routes correct themselves...
Steven Ou