:controller, how does Rails recognize them?

In the Rails guides: http://guides.rubyonrails.org/getting_started.html

It mentions that we have the following in the “routes.rb” file:

map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:id.:format’

Now, in completing the tutorial, we will add the following to
“routes.rb”:

map.root :controller => “home”

In the first two statements we have :controller, and in the last
statement, we have a :controller pointing to a value.

How does Rails determine that the first two statements point to a
:controller other than the last statement?

And, in the last statement, what are we exactly saying?

Thanks.

For, map.root :controller => “home”, I noticed that .root is a method
that tells Rails that this route is applied to requests made for the
root of the site.

http://guides.rubyonrails.org/routing.html

In the first two statements we have :controller, and in the last
statement, we have a :controller pointing to a value.

How does Rails determine that the first two statements point to a
:controller other than the last statement?

Because it’s mapping a URL pattern to a controller and action. For
example,
it means that:

http://www.example.com/users

Will go to the UsersController’s index action (because index is the
default
action) with no id (as nil is the default for a missing parameter at the
end).

http://www.example.com/users/show/1

Will map to the show actions of UsersController passing in a params[:id]
of
1.

And, in the last statement, what are we exactly saying?

That the / (http://www.example.com/) should go to the HomeController
class’s
index action (as index is the default as above).

Cheers,

Andy

Thanks Andy.