aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorTim Rogers <tim@gocardless.com>2016-07-07 10:48:13 +0100
committerTim Rogers <tim@gocardless.com>2016-07-07 10:48:13 +0100
commitba3dd5ca04e1b70afab964d32f9c0a6f9cace61c (patch)
tree5ac62d7b0b5509cfc523a461eddd16390753c521 /README.md
parent6038a548fd6bf5722f8b4fd19ec2232c887945ce (diff)
downloadrails-ba3dd5ca04e1b70afab964d32f9c0a6f9cace61c.tar.gz
rails-ba3dd5ca04e1b70afab964d32f9c0a6f9cace61c.tar.bz2
rails-ba3dd5ca04e1b70afab964d32f9c0a6f9cace61c.zip
Changes to a dupped `ActionController::Parameters` mutate the original
When `ActionController::Parameters` is duplicated with `#dup`, it doesn't create a duplicate of the instance variables (e.g. `@parameters`) but rather maintains the reference (see <http://ruby-doc.org/core-2.3.1/Object.html>). Given that the parameters object is often manipulated as if it were a hash (e.g. with `#delete` and similar methods), this leads to unexpected behaviour, like the following: ``` params = ActionController::Parameters.new(foo: "bar") duplicated_params = params.dup duplicated_params.delete(:foo) params == duplicated_params ``` This fixes the bug by defining a private `#initialize_copy` method, used internally by `#dup`, which makes a copy of `@parameters`.
Diffstat (limited to 'README.md')
0 files changed, 0 insertions, 0 deletions