How different is it from defining all the routes manually?
It's not different, in that it's more of a convenience. Why would you want to define all your routes by hand, that can be quite tedious. So the common CRUD actions are mapped automatically, below is an example using a contacts controller:
map.resources :contacts
... or in Rails 3 ...
resources :contacts
http_verb - action - route
GET - index - /contacts
GET - show - /contacts/5
GET - new - /contacts/new
POST - create - /contacts/create
GET - edit - /contacts/5/edit
PUT - update - /contacts/5
DELETE - destroy - /contacts/5
These are commonly referred to as the "7 Restful Actions," however you can add your own custom routes if needed (although you're strongly encouraged to use the 7 whenever possible).
How do you add additional resources/routes?
Adding additional routes is easy. First you want to decide if you're working with a collection or a specific member, then also consider if the action is creating or updating something. For update actions you want to use PUT, create POST, destroying uses DELETE, and anything else is probably a GET.
map.resources :contacts, :collection => { :new_this_month => :get },
:member => { :make_featured_person => :put }
... or in Rails 3 ...
resources :contacts do
collection do
get 'new_this_month'
end
member do
put 'make_featured_person'
end
end
http_verb - action - route
GET - new_this_month - /contacts/new_this_month
PUT - make_featured_person - /contacts/5/make_featured_person
Most of the time the 7 Restful Actions are plenty enough, but in some situations you'll need custom routes. This is why Rails handles the most common case and gives you the ability to handle unique cases.