views:

26

answers:

1

Why in Rails 3 do you have to uncomment match ':controller(/:action(/:id(.:format)))' (as seen in this Hello World article) to make the index method of the hello controller be called when you go to http://localhost:3000/hello? Can somebody please explain why we have to do this in Rails 3 but not Rails 2, and is this a normal thing for Rails 3 or is it some kind of hack?

+4  A: 

That particular match is sort of a catch-all for any requests that haven't already been defined.

Ideally you should be using Resource Routing, but that matcher still exists as legacy support.

It's commented out by default because Rails assumes that if a user attempts to access a route that you didn't explicitly define, it should cause a 404 error instead of a 500 error, which is what would happen if I tried to access http://localhost:3000/hello with that matcher enabled, because there's no 'hello' controller.

rspeicher