提交 cbc09180 编写于 作者: K Ken Greeff 提交者: Rafael França

Documentation for fixed controller param behaviour (#35764)

上级 8b7164c3
......@@ -184,6 +184,34 @@
* Matches behavior of `Hash#each` in `ActionController::Parameters#each`.
Rails 5.0 introduced a bug when looping through controller params using an each block. The value would be returned as a string e.g.
# Parameters: {"param"=>"1", "param_two"=>"2"}
def index
params.each do |name|
puts name
end
end
# Prints
# param
# param_two
In Rails 5.2 the bug has been fixed and name will be an array (which was the behaviour for all versions prior to 5.0), instead of a string.
To fix the code above simply change as per example below:
# Parameters: {"param"=>"1", "param_two"=>"2"}
def index
params.each do |name, value|
puts name
end
end
# Prints
# param
# param_two
*Dominic Cleal*
* Add `Referrer-Policy` header to default headers set.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册