Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
03cbd967
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,体验更适合开发者的 AI 搜索 >>
提交
03cbd967
编写于
3月 09, 2011
作者:
A
Andrew White
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Filter params that return nil for to_param and allow through false values
上级
f41dd99b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
13 addition
and
2 deletion
+13
-2
actionpack/CHANGELOG
actionpack/CHANGELOG
+4
-0
actionpack/lib/action_dispatch/http/url.rb
actionpack/lib/action_dispatch/http/url.rb
+1
-1
actionpack/lib/action_view/helpers/prototype_helper.rb
actionpack/lib/action_view/helpers/prototype_helper.rb
+0
-1
actionpack/test/controller/url_for_test.rb
actionpack/test/controller/url_for_test.rb
+8
-0
未找到文件。
actionpack/CHANGELOG
浏览文件 @
03cbd967
*
Rails
3.1.0
(
unreleased
)*
*
URL
parameters
which
return
false
for
to_param
now
appear
in
the
query
string
(
previously
they
were
removed
)
[
Andrew
White
]
*
URL
parameters
which
return
nil
for
to_param
are
now
removed
from
the
query
string
[
Andrew
White
]
*
ActionDispatch
::
MiddlewareStack
now
uses
composition
over
inheritance
.
It
is
no
longer
an
array
which
means
there
may
be
methods
missing
that
were
not
tested
.
...
...
actionpack/lib/action_dispatch/http/url.rb
浏览文件 @
03cbd967
...
...
@@ -41,7 +41,7 @@ def url_for(options = {})
path
=
options
.
delete
(
:path
)
||
''
params
=
options
[
:params
]
||
{}
params
.
reject!
{
|
k
,
v
|
!
v
}
params
.
reject!
{
|
k
,
v
|
v
.
to_param
.
nil?
}
rewritten_url
<<
(
options
[
:trailing_slash
]
?
path
.
sub
(
/\?|\z/
)
{
"/"
+
$&
}
:
path
)
rewritten_url
<<
"?
#{
params
.
to_query
}
"
unless
params
.
empty?
...
...
actionpack/lib/action_view/helpers/prototype_helper.rb
浏览文件 @
03cbd967
...
...
@@ -131,7 +131,6 @@ def remote_function(options)
"new Ajax.Updater(
#{
update
}
, "
url_options
=
options
[
:url
]
url_options
=
url_options
.
merge
(
:escape
=>
false
)
if
url_options
.
is_a?
(
Hash
)
function
<<
"'
#{
ERB
::
Util
.
html_escape
(
escape_javascript
(
url_for
(
url_options
)))
}
'"
function
<<
",
#{
javascript_options
}
)"
...
...
actionpack/test/controller/url_for_test.rb
浏览文件 @
03cbd967
...
...
@@ -311,6 +311,14 @@ def test_with_hash_with_indifferent_access
assert_equal
(
"/c/a"
,
W
.
new
.
url_for
(
HashWithIndifferentAccess
.
new
(
'controller'
=>
'c'
,
'action'
=>
'a'
,
'only_path'
=>
true
)))
end
def
test_url_params_with_nil_to_param_are_not_in_url
assert_equal
(
"/c/a"
,
W
.
new
.
url_for
(
:only_path
=>
true
,
:controller
=>
'c'
,
:action
=>
'a'
,
:id
=>
Struct
.
new
(
:to_param
).
new
(
nil
)))
end
def
test_false_url_params_are_included_in_query
assert_equal
(
"/c/a?show=false"
,
W
.
new
.
url_for
(
:only_path
=>
true
,
:controller
=>
'c'
,
:action
=>
'a'
,
:show
=>
false
))
end
private
def
extract_params
(
url
)
url
.
split
(
'?'
,
2
).
last
.
split
(
'&'
).
sort
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录