instance method namespace

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

namespace(name, options = {}, &block)

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.

Parameters

name req
options opt = {}
block block
Source
# File actionpack/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

Defined in actionpack/lib/action_controller/routing/route_set.rb line 47 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionController::Routing::RouteSet::Mapper

Type at least 2 characters to search.

↑↓ navigate · open · esc close