Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
fef10640
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,发现更多精彩内容 >>
提交
fef10640
编写于
10月 07, 2015
作者:
A
Andrew White
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21804 from merhard/mounted_engine_route_fix
Mounted engine route fix
上级
54f3a18e
bcfbd8ba
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
64 addition
and
2 deletion
+64
-2
actionpack/CHANGELOG.md
actionpack/CHANGELOG.md
+8
-0
actionpack/lib/action_dispatch/routing/mapper.rb
actionpack/lib/action_dispatch/routing/mapper.rb
+1
-0
actionpack/lib/action_dispatch/routing/route_set.rb
actionpack/lib/action_dispatch/routing/route_set.rb
+6
-2
railties/test/railties/engine_test.rb
railties/test/railties/engine_test.rb
+49
-0
未找到文件。
actionpack/CHANGELOG.md
浏览文件 @
fef10640
*
Fix regression in mounted engine named routes generation for app deployed to
a subdirectory.
`relative_url_root`
was prepended to the path twice (e.g.
"/subdir/subdir/engine_path" instead of "/subdir/engine_path")
Fixes #20920. Fixes #21459.
*Matthew Erhard*
*
ActionDispatch::Response#new no longer applies default headers. If you want
default headers applied to the response object, then call
`ActionDispatch::Response.create`
. This change only impacts people who are
...
...
actionpack/lib/action_dispatch/routing/mapper.rb
浏览文件 @
fef10640
...
...
@@ -665,6 +665,7 @@ def optimize_routes_generation?; false; end
super
(
options
)
else
prefix_options
=
options
.
slice
(
*
_route
.
segment_keys
)
prefix_options
[
:relative_url_root
]
=
''
.
freeze
# we must actually delete prefix segment keys to avoid passing them to next url_for
_route
.
segment_keys
.
each
{
|
k
|
options
.
delete
(
k
)
}
_routes
.
url_helpers
.
send
(
"
#{
name
}
_path"
,
prefix_options
)
...
...
actionpack/lib/action_dispatch/routing/route_set.rb
浏览文件 @
fef10640
...
...
@@ -656,14 +656,18 @@ def generate(route_key, options, recall = {})
RESERVED_OPTIONS
=
[
:host
,
:protocol
,
:port
,
:subdomain
,
:domain
,
:tld_length
,
:trailing_slash
,
:anchor
,
:params
,
:only_path
,
:script_name
,
:original_script_name
]
:original_script_name
,
:relative_url_root
]
def
optimize_routes_generation?
default_url_options
.
empty?
end
def
find_script_name
(
options
)
options
.
delete
(
:script_name
)
||
relative_url_root
||
''
options
.
delete
(
:script_name
)
||
find_relative_url_root
(
options
)
||
''
end
def
find_relative_url_root
(
options
)
options
.
delete
(
:relative_url_root
)
||
relative_url_root
end
def
path_for
(
options
,
route_name
=
nil
)
...
...
railties/test/railties/engine_test.rb
浏览文件 @
fef10640
...
...
@@ -1304,6 +1304,55 @@ def index
assert_equal
'/foo/bukkits/bukkit'
,
last_response
.
body
end
test
"paths are properly generated when application is mounted at sub-path and relative_url_root is set"
do
add_to_config
"config.relative_url_root = '/foo'"
@plugin
.
write
"lib/bukkits.rb"
,
<<-
RUBY
module Bukkits
class Engine < ::Rails::Engine
isolate_namespace Bukkits
end
end
RUBY
app_file
"app/controllers/bar_controller.rb"
,
<<-
RUBY
class BarController < ApplicationController
def index
render text: bukkits.bukkit_path
end
end
RUBY
app_file
"config/routes.rb"
,
<<-
RUBY
Rails.application.routes.draw do
get '/bar' => 'bar#index', :as => 'bar'
mount Bukkits::Engine => "/bukkits", :as => "bukkits"
end
RUBY
@plugin
.
write
"config/routes.rb"
,
<<-
RUBY
Bukkits::Engine.routes.draw do
get '/bukkit' => 'bukkit#index'
end
RUBY
@plugin
.
write
"app/controllers/bukkits/bukkit_controller.rb"
,
<<-
RUBY
class Bukkits::BukkitController < ActionController::Base
def index
render text: main_app.bar_path
end
end
RUBY
boot_rails
get
(
"/bukkits/bukkit"
,
{},
{
'SCRIPT_NAME'
=>
'/foo'
})
assert_equal
'/foo/bar'
,
last_response
.
body
get
(
"/bar"
,
{},
{
'SCRIPT_NAME'
=>
'/foo'
})
assert_equal
'/foo/bukkits/bukkit'
,
last_response
.
body
end
private
def
app
Rails
.
application
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录