Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
8db03822
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8db03822
编写于
12月 02, 2009
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move controller namespace tracking into route set so it gets
reloaded in dev mode
上级
4dee277a
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
37 addition
and
46 deletion
+37
-46
actionpack/lib/action_dispatch/routing.rb
actionpack/lib/action_dispatch/routing.rb
+0
-41
actionpack/lib/action_dispatch/routing/deprecated_mapper.rb
actionpack/lib/action_dispatch/routing/deprecated_mapper.rb
+1
-1
actionpack/lib/action_dispatch/routing/mapper.rb
actionpack/lib/action_dispatch/routing/mapper.rb
+1
-1
actionpack/lib/action_dispatch/routing/route_set.rb
actionpack/lib/action_dispatch/routing/route_set.rb
+34
-2
railties/lib/rails/application.rb
railties/lib/rails/application.rb
+1
-1
未找到文件。
actionpack/lib/action_dispatch/routing.rb
浏览文件 @
8db03822
...
...
@@ -265,51 +265,10 @@ module Routing
SEPARATORS
=
%w( / . ? )
HTTP_METHODS
=
[
:get
,
:head
,
:post
,
:put
,
:delete
,
:options
]
CONTROLLER_REGEXP
=
/[_a-zA-Z0-9]+/
# The root paths which may contain controller files
mattr_accessor
:controller_paths
self
.
controller_paths
=
[]
# A helper module to hold URL related helpers.
module
Helpers
include
ActionController
::
PolymorphicRoutes
end
class
<<
self
def
controller_constraints
@controller_constraints
||=
begin
source
=
controller_namespaces
.
map
{
|
ns
|
"
#{
Regexp
.
escape
(
ns
)
}
/
#{
CONTROLLER_REGEXP
.
source
}
"
}
source
<<
CONTROLLER_REGEXP
.
source
Regexp
.
compile
(
source
.
sort
.
reverse
.
join
(
'|'
))
end
end
def
clear_controller_cache!
@controller_constraints
=
nil
end
private
def
controller_namespaces
namespaces
=
Set
.
new
# Find any nested controllers already in memory
ActionController
::
Base
.
subclasses
.
each
do
|
klass
|
controller_name
=
klass
.
underscore
namespaces
<<
controller_name
.
split
(
'/'
)[
0
...-
1
].
join
(
'/'
)
end
# Find namespaces in controllers/ directory
controller_paths
.
each
do
|
load_path
|
load_path
=
File
.
expand_path
(
load_path
)
Dir
[
"
#{
load_path
}
/**/*_controller.rb"
].
collect
do
|
path
|
namespaces
<<
File
.
dirname
(
path
).
sub
(
/
#{
load_path
}
\/?/
,
''
)
end
end
namespaces
.
delete
(
''
)
namespaces
end
end
end
end
actionpack/lib/action_dispatch/routing/deprecated_mapper.rb
浏览文件 @
8db03822
...
...
@@ -113,7 +113,7 @@ def connect(path, options = {})
end
end
requirements
[
:controller
]
||=
Routing
.
controller_constraints
requirements
[
:controller
]
||=
@set
.
controller_constraints
if
defaults
[
:controller
]
defaults
[
:action
]
||=
'index'
...
...
actionpack/lib/action_dispatch/routing/mapper.rb
浏览文件 @
8db03822
...
...
@@ -383,7 +383,7 @@ def match(*args)
constraints
.
reject!
{
|
k
,
v
|
segment_keys
.
include?
(
k
.
to_s
)
}
conditions
.
merge!
(
constraints
)
requirements
[
:controller
]
||=
Routing
.
controller_constraints
requirements
[
:controller
]
||=
@set
.
controller_constraints
if
via
=
options
[
:via
]
via
=
Array
(
via
).
map
{
|
m
|
m
.
to_s
.
upcase
}
...
...
actionpack/lib/action_dispatch/routing/route_set.rb
浏览文件 @
8db03822
...
...
@@ -202,10 +202,11 @@ def formatted_#{selector}(*args) #
end
end
attr_accessor
:routes
,
:named_routes
,
:configuration_files
attr_accessor
:routes
,
:named_routes
,
:configuration_files
,
:controller_paths
def
initialize
self
.
configuration_files
=
[]
self
.
controller_paths
=
[]
self
.
routes
=
[]
self
.
named_routes
=
NamedRouteCollection
.
new
...
...
@@ -252,7 +253,7 @@ def configuration_file
def
load!
# Clear the controller cache so we may discover new ones
Routing
.
clear_controller_cache!
@controller_constraints
=
nil
load_routes!
end
...
...
@@ -297,6 +298,37 @@ def routes_changed_at
routes_changed_at
end
CONTROLLER_REGEXP
=
/[_a-zA-Z0-9]+/
def
controller_constraints
@controller_constraints
||=
begin
source
=
controller_namespaces
.
map
{
|
ns
|
"
#{
Regexp
.
escape
(
ns
)
}
/
#{
CONTROLLER_REGEXP
.
source
}
"
}
source
<<
CONTROLLER_REGEXP
.
source
Regexp
.
compile
(
source
.
sort
.
reverse
.
join
(
'|'
))
end
end
def
controller_namespaces
namespaces
=
Set
.
new
# Find any nested controllers already in memory
ActionController
::
Base
.
subclasses
.
each
do
|
klass
|
controller_name
=
klass
.
underscore
namespaces
<<
controller_name
.
split
(
'/'
)[
0
...-
1
].
join
(
'/'
)
end
# Find namespaces in controllers/ directory
controller_paths
.
each
do
|
load_path
|
load_path
=
File
.
expand_path
(
load_path
)
Dir
[
"
#{
load_path
}
/**/*_controller.rb"
].
collect
do
|
path
|
namespaces
<<
File
.
dirname
(
path
).
sub
(
/
#{
load_path
}
\/?/
,
''
)
end
end
namespaces
.
delete
(
''
)
namespaces
end
def
add_route
(
app
,
conditions
=
{},
requirements
=
{},
defaults
=
{},
name
=
nil
)
route
=
Route
.
new
(
app
,
conditions
,
requirements
,
defaults
,
name
)
@set
.
add_route
(
*
route
)
...
...
railties/lib/rails/application.rb
浏览文件 @
8db03822
...
...
@@ -387,7 +387,7 @@ def call(env)
initializer
:initialize_routing
do
next
unless
configuration
.
frameworks
.
include?
(
:action_controller
)
ActionController
::
Routing
.
controller_paths
+=
configuration
.
controller_paths
ActionController
::
Routing
::
Routes
.
controller_paths
+=
configuration
.
controller_paths
ActionController
::
Routing
::
Routes
.
add_configuration_file
(
configuration
.
routes_configuration_file
)
ActionController
::
Routing
::
Routes
.
reload!
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录