Module: ActionDispatch::Routing::Mapper::Base

### Home Classes Methods

### In Files

- lib/action_dispatch/routing/mapper.rb

### Methods

- #default_url_options
- #default_url_options=
- #match
- #mount
- #root
- #with_default_scope

### Class/Module Index

Quicksearch

- ActionDispatch
- ActionDispatch::Assertions
- ActionDispatch::Assertions::DomAssertions
- ActionDispatch::Assertions::ResponseAssertions
- ActionDispatch::Assertions::RoutingAssertions
- ActionDispatch::Assertions::SelectorAssertions
- ActionDispatch::Assertions::TagAssertions
- ActionDispatch::BestStandardsSupport
- ActionDispatch::BodyProxy
- ActionDispatch::Callbacks
- ActionDispatch::Cookies
- ActionDispatch::Cookies::CookieOverflow
- ActionDispatch::DebugExceptions
- ActionDispatch::ExceptionWrapper
- ActionDispatch::FileHandler
- ActionDispatch::Flash
- ActionDispatch::Flash::FlashHash
- ActionDispatch::Head
- ActionDispatch::Http
- ActionDispatch::Http::Cache
- ActionDispatch::Http::Cache::Request
- ActionDispatch::Http::Cache::Response
- ActionDispatch::Http::FilterParameters
- ActionDispatch::Http::Headers
- ActionDispatch::Http::MimeNegotiation
- ActionDispatch::Http::ParameterFilter
- ActionDispatch::Http::Parameters
- ActionDispatch::Http::URL
- ActionDispatch::Http::Upload
- ActionDispatch::Http::UploadedFile
- ActionDispatch::Integration
- ActionDispatch::Integration::RequestHelpers
- ActionDispatch::Integration::Runner
- ActionDispatch::Integration::Session
- ActionDispatch::IntegrationTest
- ActionDispatch::MiddlewareStack
- ActionDispatch::MiddlewareStack::Middleware
- ActionDispatch::ParamsParser
- ActionDispatch::PerformanceTest
- ActionDispatch::PublicExceptions
- ActionDispatch::RailsEntityStore
- ActionDispatch::RailsMetaStore
- ActionDispatch::Railtie
- ActionDispatch::Reloader
- ActionDispatch::RemoteIp
- ActionDispatch::RemoteIp::GetIp
- ActionDispatch::RemoteIp::IpSpoofAttackError
- ActionDispatch::Request
- ActionDispatch::RequestId
- ActionDispatch::Rescue
- ActionDispatch::Response
- ActionDispatch::Routing
- ActionDispatch::Routing::Mapper
- ActionDispatch::Routing::Mapper::Base
- ActionDispatch::Routing::Mapper::HttpHelpers
- ActionDispatch::Routing::Mapper::Resources
- ActionDispatch::Routing::Mapper::Scoping
- ActionDispatch::Routing::PolymorphicRoutes
- ActionDispatch::Routing::Redirection
- ActionDispatch::Routing::RouteSet
- ActionDispatch::Routing::RouteSet::MountedHelpers
- ActionDispatch::Routing::UrlFor
- ActionDispatch::Session
- ActionDispatch::Session::AbstractStore
- ActionDispatch::Session::CacheStore
- ActionDispatch::Session::Compatibility
- ActionDispatch::Session::CookieStore
- ActionDispatch::Session::DestroyableSession
- ActionDispatch::Session::MemCacheStore
- ActionDispatch::Session::StaleSessionCheck
- ActionDispatch::ShowExceptions
- ActionDispatch::Static
- ActionDispatch::TestProcess
- ActionDispatch::TestRequest
- ActionDispatch::TestResponse
- ActionController
- ActionController::Base
- ActionController::Caching
- ActionController::Caching::Actions
- ActionController::Caching::Actions::ActionCachePath
- ActionController::Caching::Actions::ClassMethods
- ActionController::Caching::ConfigMethods
- ActionController::Caching::Fragments
- ActionController::Caching::Pages
- ActionController::Caching::Pages::ClassMethods
- ActionController::Caching::Sweeping
- ActionController::Compatibility
- ActionController::ConditionalGet
- ActionController::Cookies
- ActionController::DataStreaming
- ActionController::Flash
- ActionController::ForceSSL
- ActionController::ForceSSL::ClassMethods
- ActionController::Head
- ActionController::Helpers
- ActionController::Helpers::ClassMethods
- ActionController::HideActions
- ActionController::HideActions::ClassMethods
- ActionController::HttpAuthentication
- ActionController::HttpAuthentication::Basic
- ActionController::HttpAuthentication::Basic::ControllerMethods
- ActionController::HttpAuthentication::Basic::ControllerMethods::ClassMethods
- ActionController::HttpAuthentication::Digest
- ActionController::HttpAuthentication::Digest::ControllerMethods
- ActionController::HttpAuthentication::Token
- ActionController::HttpAuthentication::Token::ControllerMethods
- ActionController::ImplicitRender
- ActionController::Instrumentation
- ActionController::Instrumentation::ClassMethods
- ActionController::LogSubscriber
- ActionController::Metal
- ActionController::Middleware
- ActionController::Middleware::ActionMiddleware
- ActionController::MimeResponds
- ActionController::MimeResponds::ClassMethods
- ActionController::ParamsWrapper
- ActionController::ParamsWrapper::ClassMethods
- ActionController::RackDelegation
- ActionController::Railtie
- ActionController::Railties
- ActionController::Railties::Paths
- ActionController::RecordIdentifier
- ActionController::Redirecting
- ActionController::Renderers
- ActionController::Renderers::All
- ActionController::Renderers::ClassMethods
- ActionController::Rendering
- ActionController::RequestForgeryProtection
- ActionController::RequestForgeryProtection::ClassMethods
- ActionController::Rescue
- ActionController::Responder
- ActionController::SessionManagement
- ActionController::SessionManagement::ClassMethods
- ActionController::Streaming
- ActionController::TemplateAssertions
- ActionController::TestCase
- ActionController::TestCase::Behavior
- ActionController::TestCase::Behavior::ClassMethods
- ActionController::TestCase::RaiseActionExceptions
- ActionController::TestResponse
- ActionController::Testing
- ActionController::Testing::ClassMethods
- ActionController::UrlFor
- ActionView
- ActionView::Base
- ActionView::Context
- ActionView::FileSystemResolver
- ActionView::FixtureResolver
- ActionView::Helpers
- ActionView::Helpers::ActiveModelHelper
- ActionView::Helpers::ActiveModelInstanceTag
- ActionView::Helpers::AssetPaths
- ActionView::Helpers::AssetTagHelper
- ActionView::Helpers::AssetTagHelper::AssetIncludeTag
- ActionView::Helpers::AssetTagHelper::JavascriptIncludeTag
- ActionView::Helpers::AssetTagHelper::JavascriptTagHelpers
- ActionView::Helpers::AssetTagHelper::JavascriptTagHelpers::ClassMethods
- ActionView::Helpers::AssetTagHelper::StylesheetIncludeTag
- ActionView::Helpers::AssetTagHelper::StylesheetTagHelpers
- ActionView::Helpers::AssetTagHelper::StylesheetTagHelpers::ClassMethods
- ActionView::Helpers::AtomFeedHelper
- ActionView::Helpers::AtomFeedHelper::AtomBuilder
- ActionView::Helpers::AtomFeedHelper::AtomFeedBuilder
- ActionView::Helpers::CacheHelper
- ActionView::Helpers::CaptureHelper
- ActionView::Helpers::CsrfHelper
- ActionView::Helpers::DateHelper
- ActionView::Helpers::DateHelperInstanceTag
- ActionView::Helpers::DebugHelper
- ActionView::Helpers::FormBuilder
- ActionView::Helpers::FormHelper
- ActionView::Helpers::FormOptionsHelper
- ActionView::Helpers::FormTagHelper
- ActionView::Helpers::InstanceTag
- ActionView::Helpers::JavaScriptHelper
- ActionView::Helpers::OutputSafetyHelper
- ActionView::Helpers::RecordTagHelper
- ActionView::Helpers::RenderingHelper
- ActionView::Helpers::SanitizeHelper
- ActionView::Helpers::TagHelper
- ActionView::Helpers::TextHelper
- ActionView::Helpers::TranslationHelper
- ActionView::Helpers::UrlHelper
- ActionView::LogSubscriber
- ActionView::LookupContext
- ActionView::LookupContext::DetailsCache
- ActionView::LookupContext::ViewPaths
- ActionView::NullResolver
- ActionView::PartialRenderer
- ActionView::Railtie
- ActionView::Renderer
- ActionView::Resolver
- ActionView::Resolver::Path
- ActionView::Template
- ActionView::Template::Handlers
- ActionView::Template::Handlers::Builder
- ActionView::Template::Handlers::ERB
- ActionView::Template::Handlers::Erubis
- ActionView::TestCase
- ActionView::TestCase::Behavior
- ActionView::TestCase::Behavior::ClassMethods
- ActionView::TestCase::Behavior::Locals
- ActionView::TestCase::TestController
- AbstractController
- AbstractController::ActionNotFound
- AbstractController::AssetPaths
- AbstractController::Base
- AbstractController::Callbacks
- AbstractController::Callbacks::ClassMethods
- AbstractController::Collector
- AbstractController::DoubleRenderError
- AbstractController::Error
- AbstractController::Helpers
- AbstractController::Helpers::ClassMethods
- AbstractController::Layouts
- AbstractController::Layouts::ClassMethods
- AbstractController::Layouts::ClassMethods::LayoutConditions
- AbstractController::Logger
- AbstractController::Railties
- AbstractController::Railties::RoutesHelpers
- AbstractController::Rendering
- AbstractController::Rendering::ClassMethods
- AbstractController::Translation
- AbstractController::UrlFor
- AbstractController::UrlFor::ClassMethods
- AbstractController::ViewPaths
- AbstractController::ViewPaths::ClassMethods
- Sprockets
- Sprockets::Bootstrap
- Sprockets::Compressors
- Sprockets::Helpers
- Sprockets::Helpers::IsolatedHelper
- Sprockets::Helpers::RailsHelper
- Sprockets::Helpers::RailsHelper::AssetPaths
- Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError
- Sprockets::Railtie
- Sprockets::StaticCompiler
- HTML
- HTML::FullSanitizer
- HTML::LinkSanitizer
- HTML::Sanitizer
- HTML::Selector
- HTML::Tag
- HTML::WhiteListSanitizer
- Mime
- Mime::Mimes
- Mime::Type
- ActionPack
- Object
- Rack

No matching classes.

# ActionDispatch::Routing::Mapper::Base

### Public Instance Methods

default_url_options(options) click to toggle source
Alias for: default_url_options=
default_url_options=(options) click to toggle source

    # File lib/action_dispatch/routing/mapper.rb, line 412
    def default_url_options=(options)
      @set.default_url_options = options
    end

Also aliased as: default_url_options
match(path, options=nil) click to toggle source

Matches a url pattern to one or more routes. Any symbols in a pattern are interpreted as url query parameters and thus available as `params` in an action:

    # sets :controller, :action and :id in params
    match ':controller/:action/:id'

Two of these symbols are special, `:controller` maps to the controller and `:action` to the controller's action. A pattern can also map wildcard segments (globs) to params:

    match 'songs/*category/:title' => 'songs#show'

    # 'songs/rock/classic/stairway-to-heaven' sets
    #  params[:category] = 'rock/classic'
    #  params[:title] = 'stairway-to-heaven'

When a pattern points to an internal route, the route's `:action` and `:controller` should be set in options or hash shorthand. Examples:

    match 'photos/:id' => 'photos#show'
    match 'photos/:id', :to => 'photos#show'
    match 'photos/:id', :controller => 'photos', :action => 'show'

A pattern can also point to a `Rack` endpoint i.e. anything that responds to `call`:

    match 'photos/:id' => lambda {|hash| [200, {}, "Coming soon"] }
    match 'photos/:id' => PhotoRackApp
    # Yes, controller actions are just rack endpoints
    match 'photos/:id' => PhotosController.action(:show)

### Options

Any options not seen here are passed on as params with the url.

:controller

  The route's controller.

:action

  The route's action.

:path

  The path prefix for the routes.

:module

  The namespace for :controller.

      match 'path' => 'c#a', :module => 'sekret', :controller => 'posts'
      #=> Sekret::PostsController

  See `Scoping#namespace` for its scope equivalent.

:as

  The name used to generate routing helpers.

:via

  Allowed HTTP verb(s) for route.

      match 'path' => 'c#a', :via => :get
      match 'path' => 'c#a', :via => [:get, :post]

:to

  Points to a `Rack` endpoint. Can be an object that responds to `call` or a string representing a controller's action.

      match 'path', :to => 'controller#action'
      match 'path', :to => lambda { |env| [200, {}, "Success!"] }
      match 'path', :to => RackApp

:on

  Shorthand for wrapping routes in a specific RESTful context. Valid values are `:member`, `:collection`, and `:new`. Only use within `resource(s)` block. For example:

      resource :bar do
        match 'foo' => 'c#a', :on => :member, :via => [:get, :post]
      end

  Is equivalent to:

      resource :bar do
        member do
          match 'foo' => 'c#a', :via => [:get, :post]
        end
      end

:constraints

  Constrains parameters with a hash of regular expressions or an object that responds to `matches?`

      match 'path/:id', :constraints => { :id => /[A-Z]\d{5}/ }

      class Blacklist
        def matches?(request) request.remote_ip == '1.2.3.4' end
      end
      match 'path' => 'c#a', :constraints => Blacklist.new

  See `Scoping#constraints` for more examples with its scope equivalent.

:defaults

  Sets defaults for parameters

      # Sets params[:format] to 'jpg' by default
      match 'path' => 'c#a', :defaults => { :format => 'jpg' }

  See `Scoping#defaults` for its scope equivalent.

:anchor

  Boolean to anchor a `match` pattern. Default is true. When set to false, the pattern matches any request prefixed with the given path.

      # Matches any request starting with 'path'
      match 'path' => 'c#a', :anchor => false

    # File lib/action_dispatch/routing/mapper.rb, line 371
    def match(path, options=nil)
    end

mount(app, options = nil) click to toggle source

Mount a Rack-based application to be used within the application.

    mount SomeRackApp, :at => "some_route"

Alternatively:

    mount(SomeRackApp => "some_route")

For options, see `match`, as `mount` uses it internally.

All mounted applications come with routing helpers to access them. These are named after the class specified, so for the above example the helper is either `some_rack_app_path` or `some_rack_app_url`. To customize this helper's name, use the `:as` option:

    mount(SomeRackApp => "some_route", :as => "exciting")

This will generate the `exciting_path` and `exciting_url` helpers which can be used to navigate to this mounted app.

    # File lib/action_dispatch/routing/mapper.rb, line 393
    def mount(app, options = nil)
      if options
        path = options.delete(:at)
      else
        options = app
        app, path = options.find { |k, v| k.respond_to?(:call) }
        options.delete(app) if app
      end

      raise "A rack application must be specified" unless path

      options[:as] ||= app_name(app)

      match(path, options.merge(:to => app, :anchor => false, :format => false))

      define_generate_prefix(app, options[:as])
      self
    end

root(options = {}) click to toggle source

You can specify what Rails should route "/" to with the root method:

    root :to => 'pages#main'

For options, see `match`, as `root` uses it internally.

You should put the root route at the top of `config/routes.rb`, because this means it will be matched first. As this is the most popular route of most Rails applications, this is beneficial.

    # File lib/action_dispatch/routing/mapper.rb, line 252
    def root(options = {})
      match '/', { :as => :root }.merge(options)
    end

with_default_scope(scope, &block) click to toggle source

    # File lib/action_dispatch/routing/mapper.rb, line 417
    def with_default_scope(scope, &block)
      scope(scope) do
        instance_exec(&block)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.