Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
092b148b
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,发现更多精彩内容 >>
提交
092b148b
编写于
7月 05, 2010
作者:
P
Piotr Sarnacki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Engine can now serve files with ActionDispatch::Static
上级
c989d1a8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
5 deletion
+41
-5
railties/lib/rails/application/configuration.rb
railties/lib/rails/application/configuration.rb
+1
-1
railties/lib/rails/engine.rb
railties/lib/rails/engine.rb
+10
-1
railties/lib/rails/engine/configuration.rb
railties/lib/rails/engine/configuration.rb
+3
-2
railties/lib/rails/railtie/configuration.rb
railties/lib/rails/railtie/configuration.rb
+1
-1
railties/test/railties/engine_test.rb
railties/test/railties/engine_test.rb
+26
-0
未找到文件。
railties/lib/rails/application/configuration.rb
浏览文件 @
092b148b
...
...
@@ -11,7 +11,7 @@ class Configuration < ::Rails::Engine::Configuration
:encoding
,
:consider_all_requests_local
,
:dependency_loading
,
:filter_parameters
,
:log_level
,
:logger
,
:preload_frameworks
,
:reload_plugins
,
:secret_token
,
:se
rve_static_assets
,
:se
ssion_options
,
:secret_token
,
:session_options
,
:time_zone
,
:whiny_nils
def
initialize
(
*
)
...
...
railties/lib/rails/engine.rb
浏览文件 @
092b148b
...
...
@@ -152,13 +152,22 @@ def railties
end
def
app
@app
||=
config
.
middleware
.
build
(
endpoint
)
@app
||=
begin
config
.
middleware
=
config
.
middleware
.
merge_into
(
default_middleware_stack
)
config
.
middleware
.
build
(
endpoint
)
end
end
def
endpoint
self
.
class
.
endpoint
||
routes
end
def
default_middleware_stack
ActionDispatch
::
MiddlewareStack
.
new
.
tap
do
|
middleware
|
middleware
.
use
::
ActionDispatch
::
Static
,
paths
.
public
.
to_a
.
first
if
config
.
serve_static_assets
end
end
def
call
(
env
)
app
.
call
(
env
)
end
...
...
railties/lib/rails/engine/configuration.rb
浏览文件 @
092b148b
...
...
@@ -5,12 +5,13 @@ class Engine
class
Configuration
<
::
Rails
::
Railtie
::
Configuration
attr_reader
:root
attr_writer
:eager_load_paths
,
:autoload_once_paths
,
:autoload_paths
attr_accessor
:middleware
,
:plugins
attr_accessor
:middleware
,
:plugins
,
:serve_static_assets
def
initialize
(
root
=
nil
)
super
()
@root
=
root
@middleware
=
ActionDispatch
::
MiddlewareStack
.
new
@serve_static_assets
=
true
@middleware
=
Rails
::
Configuration
::
MiddlewareStackProxy
.
new
end
def
paths
...
...
railties/lib/rails/railtie/configuration.rb
浏览文件 @
092b148b
...
...
@@ -78,4 +78,4 @@ def method_missing(name, *args, &blk)
end
end
end
end
\ No newline at end of file
end
railties/test/railties/engine_test.rb
浏览文件 @
092b148b
...
...
@@ -127,5 +127,31 @@ class Engine < ::Rails::Engine
assert
Bukkits
::
Engine
.
config
.
yaffle_loaded
end
test
"engine can serve files"
do
@plugin
.
write
"lib/bukkits.rb"
,
<<-
RUBY
class Bukkits
class Engine < ::Rails::Engine
paths.public = "
#{
File
.
join
(
@plugin
.
path
,
"lib/bukkits/public"
)
}
"
config.serve_static_assets = true
end
end
RUBY
@plugin
.
write
"lib/bukkits/public/omg.txt"
,
<<-
RUBY
OMG
RUBY
boot_rails
Rails
::
Application
.
routes
.
draw
do
|
map
|
mount
(
Bukkits
::
Engine
=>
"/bukkits"
)
end
env
=
Rack
::
MockRequest
.
env_for
(
"/bukkits/omg.txt"
)
response
=
Rails
::
Application
.
call
(
env
)
assert_equal
response
[
2
].
path
,
File
.
join
(
@plugin
.
path
,
"lib/bukkits/public/omg.txt"
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录