Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
15ab3a98
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,发现更多精彩内容 >>
提交
15ab3a98
编写于
11月 23, 2009
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Find all controllers in memory to use for routing
上级
f987e856
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
25 deletion
+15
-25
actionpack/lib/action_dispatch/routing.rb
actionpack/lib/action_dispatch/routing.rb
+12
-7
actionpack/lib/action_dispatch/routing/route_set.rb
actionpack/lib/action_dispatch/routing/route_set.rb
+3
-1
actionpack/test/abstract_unit.rb
actionpack/test/abstract_unit.rb
+0
-12
railties/test/rails_info_controller_test.rb
railties/test/rails_info_controller_test.rb
+0
-5
未找到文件。
actionpack/lib/action_dispatch/routing.rb
浏览文件 @
15ab3a98
...
...
@@ -280,6 +280,10 @@ def controller_constraints
Regexp
.
union
(
*
possible_controllers
.
collect
{
|
n
|
Regexp
.
escape
(
n
)
})
end
def
clear_controller_cache!
@possible_controllers
=
nil
end
# Returns an array of paths, cleaned of double-slashes and relative path references.
# * "\\\" and "//" become "\\" or "/".
# * "/foo/bar/../config" becomes "/foo/config".
...
...
@@ -307,8 +311,15 @@ def possible_controllers
unless
@possible_controllers
@possible_controllers
=
[]
paths
=
controller_paths
.
select
{
|
path
|
File
.
directory?
(
path
)
&&
path
!=
"."
}
# Find any controller classes already in memory
ActionController
::
Base
.
subclasses
.
each
do
|
klass
|
controller_name
=
klass
.
underscore
controller_name
.
gsub!
(
/_controller\Z/
,
''
)
@possible_controllers
<<
controller_name
end
# Find controllers in controllers/ directory
paths
=
controller_paths
.
select
{
|
path
|
File
.
directory?
(
path
)
&&
path
!=
"."
}
seen_paths
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
true
;
false
}
normalize_paths
(
paths
).
each
do
|
load_path
|
Dir
[
"
#{
load_path
}
/**/*_controller.rb"
].
collect
do
|
path
|
...
...
@@ -326,12 +337,6 @@ def possible_controllers
end
@possible_controllers
end
# Replaces the internal list of controllers available to ActionController::Routing with the passed argument.
# ActionController::Routing.use_controllers!([ "posts", "comments", "admin/comments" ])
def
use_controllers!
(
controller_names
)
@possible_controllers
=
controller_names
end
end
end
end
actionpack/lib/action_dispatch/routing/route_set.rb
浏览文件 @
15ab3a98
...
...
@@ -246,7 +246,9 @@ def configuration_file
end
def
load!
Routing
.
use_controllers!
(
nil
)
# Clear the controller cache so we may discover new ones
# Clear the controller cache so we may discover new ones
Routing
.
clear_controller_cache!
load_routes!
end
...
...
actionpack/test/abstract_unit.rb
浏览文件 @
15ab3a98
...
...
@@ -191,20 +191,8 @@ class ::ApplicationController < ActionController::Base
end
module
ActionController
module
Routing
def
self
.
possible_controllers
@@possible_controllers
||=
[]
end
end
class
Base
include
ActionController
::
Testing
def
self
.
inherited
(
klass
)
name
=
klass
.
name
.
underscore
.
sub
(
/_controller$/
,
''
)
ActionController
::
Routing
.
possible_controllers
<<
name
unless
name
.
blank?
super
end
end
Base
.
view_paths
=
FIXTURE_LOAD_PATH
...
...
railties/test/rails_info_controller_test.rb
浏览文件 @
15ab3a98
...
...
@@ -14,17 +14,12 @@ class InfoControllerTest < ActionController::TestCase
tests
Rails
::
InfoController
def
setup
ActionController
::
Routing
.
use_controllers!
([
'rails/info'
])
ActionController
::
Routing
::
Routes
.
draw
do
|
map
|
map
.
connect
':controller/:action/:id'
end
@controller
.
stubs
(
:consider_all_requests_local
=>
false
,
:local_request?
=>
true
)
end
def
teardown
ActionController
::
Routing
.
use_controllers!
nil
end
test
"info controller does not allow remote requests"
do
@controller
.
stubs
(
:consider_all_requests_local
=>
false
,
:local_request?
=>
false
)
get
:properties
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录