命名空间
- 模块 ActionDispatch::Routing::Mapper::Base
- 模块 ActionDispatch::Routing::Mapper::Concerns
- 模块 ActionDispatch::Routing::Mapper::CustomUrls
- 模块 ActionDispatch::Routing::Mapper::HttpHelpers
- 模块 ActionDispatch::Routing::Mapper::Resources
- 模块 ActionDispatch::Routing::Mapper::Scoping
方法
包含的模块
- ActionDispatch::Routing::Mapper::Base
- ActionDispatch::Routing::Mapper::HttpHelpers
- ActionDispatch::Routing::Redirection
- ActionDispatch::Routing::Mapper::Scoping
- ActionDispatch::Routing::Mapper::Concerns
- ActionDispatch::Routing::Mapper::Resources
- ActionDispatch::Routing::Mapper::CustomUrls
常量
URL_OPTIONS | = | [:protocol, :subdomain, :domain, :host, :port] |
类公共方法
normalize_name(name) 链接
源代码: 显示 | 在 GitHub 上查看
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 412 def self.normalize_name(name) normalize_path(name)[1..-1].tr("/", "_") end
normalize_path(path) 链接
调用 Journey::Router::Utils.normalize_path,然后确保 /(:locale) 变成 (/:locale)。除了根路径,前者是正确的。
源代码: 显示 | 在 GitHub 上查看
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 397 def self.normalize_path(path) path = Journey::Router::Utils.normalize_path(path) # the path for a root URL at this point can be something like # "/(/:locale)(/:platform)/(:browser)", and we would want # "/(:locale)(/:platform)(/:browser)" reverse "/(", "/((" etc to "(/", "((/" etc path.gsub!(%r{/(\(+)/?}, '\1/') # if a path is all optional segments, change the leading "(/" back to "/(" so it # evaluates to "/" when interpreted with no options. Unless, however, at least # one secondary segment consists of a static part, ex. # "(/:locale)(/pages/:page)" path.sub!(%r{^(\(+)/}, '/\1') if %r{^(\(+[^)]+\))(\(+/:[^)]+\))*$}.match?(path) path end