Parent

Included Modules

Class/Module Index [+]

Quicksearch

ActionController::Routing::RouteSet::Mapper

Mapper instances are used to build routes. The object passed to the draw block in config/routes.rb is a Mapper instance.

Mapper instances have relatively few instance methods, in order to avoid clashes with named routes.

Public Instance Methods

connect(path, options = {}) click to toggle source

Create an unnamed route with the provided path and options. See ActionController::Routing for an introduction to routes.

# File lib/action_controller/routing/route_set.rb, line 18
def connect(path, options = {})
  @set.add_route(path, options)
end
namespace(name, options = {}, &block) click to toggle source

Enables the use of resources in a module by setting the name_prefix, path_prefix, and namespace for the model. Example:

map.namespace(:admin) do |admin|
  admin.resources :products,
    :has_many => [ :tags, :images, :variants ]
end

This will create admin_products_url pointing to “admin/products”, which will look for an Admin::ProductsController. It’ll also create admin_product_tags_url pointing to “admin/products/#{product_id}/tags”, which will look for Admin::TagsController.

# File lib/action_controller/routing/route_set.rb, line 47
def namespace(name, options = {}, &block)
  if options[:namespace]
    with_options({:path_prefix => "#{options.delete(:path_prefix)}/#{name}", :name_prefix => "#{options.delete(:name_prefix)}#{name}_", :namespace => "#{options.delete(:namespace)}#{name}/" }.merge(options), &block)
  else
    with_options({:path_prefix => name, :name_prefix => "#{name}_", :namespace => "#{name}/" }.merge(options), &block)
  end
end
root(options = {}) click to toggle source

Creates a named route called “root” for matching the root level request.

# File lib/action_controller/routing/route_set.rb, line 23
def root(options = {})
  if options.is_a?(Symbol)
    if source_route = @set.named_routes.routes[options]
      options = source_route.defaults.merge({ :conditions => source_route.conditions })
    end
  end
  named_route("root", '', options)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.