123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Routing::Mapper

Relationships & Source Files
Namespace Children
Modules:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: actionpack/lib/action_dispatch/routing/mapper.rb

Constant Summary

Resources - Included

CANONICAL_ACTIONS, RESOURCE_OPTIONS, VALID_ON_OPTIONS

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Resources - Included

#collection

To add a route to the collection:

#match

match 'path' => 'controller#action' match 'path', to: 'controller#action' match 'path', 'otherpath', on: :member, via: :get.

#member

To add a member route, add a member block into the resource block:

#namespace
#nested, #new,
#resource

Sometimes, you have a resource that clients always look up without referencing an ID.

#resources

In Rails, a resourceful route provides a mapping between HTTP verbs and URLs and controller actions.

#resources_path_names, #root, #using_match_shorthand?

Concerns - Included

#concern

Define a routing concern using a name.

#concerns

Use the named concerns.

Scoping - Included

#constraints

Parameter Restriction Allows you to constrain the nested routes based on a set of rules.

#controller

Scopes routes to a specific controller.

#defaults

Allows you to set default parameters for a route, such as this:

#namespace

Scopes routes to a specific namespace.

#scope

Scopes a set of routes to the given default options.

Redirection - Included

#redirect

Redirect any path to another path:

HttpHelpers - Included

#delete

Define a route that only recognizes HTTP DELETE.

#get

Define a route that only recognizes HTTP GET.

#patch

Define a route that only recognizes HTTP PATCH.

#post

Define a route that only recognizes HTTP POST.

#put

Define a route that only recognizes HTTP PUT.

Base - Included

#has_named_route?

Query if the following named route was already defined.

#match

Matches a url pattern to one or more routes.

#mount

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

#root

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

#with_default_scope

Class Method Details

.normalize_name(name)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 369

def self.normalize_name(name)
  normalize_path(name)[1..-1].tr("/", "_")
end

.normalize_path(path)

Invokes Journey::Router::Utils.normalize_path and ensure that (:locale) becomes (/:locale) instead of /(:locale). Except for root cases, where the latter is the correct one.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 363

def self.normalize_path(path)
  path = Journey::Router::Utils.normalize_path(path)
  path.gsub!(%r{/(\(+)/?}, '\1/') unless path =~ %r{^/\([^)]\)$}
  path
end