In the rails application, routes.rb routing has three main ways.

1: map.connect

# for routing the admin/customers section
  map.connect '/superadmin/user_asset/list_assets', :controller => "superadmin/user_asset",:action=>'list_assets'
  map.connect '/superadmin/user_asset/create_asset', :controller => "superadmin/user_asset",:action=>'create_asset'
  map.connect '/admin/collections/assign_product', :controller => "admin/collections", :action=>'assign_product' 
  map.connect '/admin/collections/remove_product', :controller => "admin/collections", :action=>'remove_product'
  map.connect '/admin/collections/update_product_list', :controller => "admin/collections", :action=>'update_product_list'


This routing is clear, the first browser to express the parameters are the relative path. The assumption that the application name for the depot.
Then have:
http://127.0.0.1/dept/superadmin/user_asset/list_assets, the request will find the controller: superadmin / user_asset in the Ways list_assets.

Second: You can rename the routing
Except in this way will be replaced by map.connect express yourself map .****(* naming names), and create a distinction between ordinary routing Nothing. Its main difference is that when you provide when naming routing, Rails will automatically provide two new URL Ways :****_ path and ****_ url, these two methods to generate point to the URL routing

map.shopping_cart '/cart', :controller => 'order_items'
  map.checkout '/checkout', :controller => 'orders', :action => 'new'
  map.thank_you "/thank_you", :controller => 'orders', :action => 'thank_you'
  map.resources :order_items, :collection => {:update => :put}


In the view and controller, we can adopt the following manner Routing
link_to 'Cart',shopping_cart_path()


Three: map.resources: exercises (rest mode)

It is the second method of promoting the use of, and behind you will be able to understand.

Routes.rb call at map.resources code, Rails can generate a set of Rest on the way the routing method. This method is easily confused, leading to confusion routing.
Examples: the use of restful_authentication plug-in (set up a user login and authentication system), the premise is that you installed the plug-ins.
Run:
ruby script/generate authenticated user sessions


The application to generate the two controllers: Sessions, Users, Add Users simultaneously model category, such as the relevant view.
Open routes.rb documents,
Show:
map.resources :users,:sessions


Show sessions_controller.rb
# This controller handles the login/logout function of the site.  
class SessionsController < ApplicationController
  # Be sure to include AuthenticationSystem in Application Controller instead
  

  # render new.rhtml
  def new
  end

  def create
    self.current_user = User.authenticate(params[:login], params[:password])
    if logged_in?
      if params[:remember_me] == "1"
        current_user.remember_me unless current_user.remember_token?
        cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
      end
      redirect_back_or_default('/')
      flash[:notice] = "Logged in successfully"
    else
      render :action => 'new'
    end
  end

  def destroy
    self.current_user.forget_me if logged_in?
    cookies.delete :auth_token
    reset_session
    flash[:notice] = "You have been logged out."
    redirect_back_or_default('/')
  end
end


It is responsible for the user to log in and out function.

See view / sessions / new.rhtml document, it is a login box.
[color=red]<% form_tag sessions_path do -%>[/color]
  <p><label for="login">Login</label><br/>
  <%= text_field_tag 'login' %></p>

  <p><label for="password">Password</label><br/>
  <%= password_field_tag 'password' %></p>

  <!-- Uncomment this if you want this functionality
  <p><label for="remember_me">Remember me:</label>
  <%= check_box_tag 'remember_me' %></p>
  -->

  <p><%= submit_tag 'Log in' %></p>
  <% end -%>


Note: the red part of the code, that is the create method SesionsController the corresponding routing sessions_path. They are automatically generated.

Rest have a default controller for the general Index, Show, New, Edit, Create, Update, Destroy method. Map.resources Rails through according to the method of the controller automatically create all the corresponding routing.