Class | ActionController::Routing::RouteSet::Mapper |
In: |
vendor/rails/actionpack/lib/action_controller/routing/route_set.rb
vendor/rails/actionpack/lib/action_controller/resources.rb |
Parent: | Object |
Create an unnamed route with the provided path and options. See ActionController::Routing for an introduction to routes.
# File vendor/rails/actionpack/lib/action_controller/routing/route_set.rb, line 16 16: def connect(path, options = {}) 17: @set.add_route(path, options) 18: end
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 vendor/rails/actionpack/lib/action_controller/routing/route_set.rb, line 45 45: def namespace(name, options = {}, &block) 46: if options[:namespace] 47: with_options({:path_prefix => "#{options.delete(:path_prefix)}/#{name}", :name_prefix => "#{options.delete(:name_prefix)}#{name}_", :namespace => "#{options.delete(:namespace)}#{name}/" }.merge(options), &block) 48: else 49: with_options({:path_prefix => name, :name_prefix => "#{name}_", :namespace => "#{name}/" }.merge(options), &block) 50: end 51: end
Creates a named route called "root" for matching the root level request.
# File vendor/rails/actionpack/lib/action_controller/routing/route_set.rb, line 21 21: def root(options = {}) 22: if options.is_a?(Symbol) 23: if source_route = @set.named_routes.routes[options] 24: options = source_route.defaults.merge({ :conditions => source_route.conditions }) 25: end 26: end 27: named_route("root", '', options) 28: end