This project is archived and is in readonly mode.
HashWithIndifferentAccess should override #store
Reported by greg (at araelium) | October 9th, 2010 @ 05:41 PM | in 3.0.2
params[:save_me]=x and params['save_me']=x are equivalent.
params.store(:save_me, x) and params.store('save_me', x) are not equivalent.
params.store(:test1, 1)
params.store('test1', 11)
params[:test2] = 2
params['test2'] = 22
Results in:
--- !map:ActiveSupport::HashWithIndifferentAccess
test1: 11
:test1: 1
test2: 22
When I am expecting
--- !map:ActiveSupport::HashWithIndifferentAccess
test1: 11
test2: 22
Comments and changes to this ticket
-
Santiago Pastorino October 9th, 2010 @ 06:16 PM
- Importance changed from to Low
Can you provide a patch with a test case? or a test case only?.
Thank you. -
Andrea Campi October 9th, 2010 @ 06:34 PM
- Tag changed from activesupport, hashwithindifferentaccess, params to activesupport, hashwithindifferentaccess, params, patched
There you go.
I implemented #store the same as #[]= but maybe one should be an alias to the other?
Would anybody ever subclass HashWithIndifferentAccess and override just one of #[]= and #store? -
Álvaro Bautista October 9th, 2010 @ 06:54 PM
- Tag changed from activesupport, hashwithindifferentaccess, params, patched to activesupport, hashwithindifferentaccess, params
I agree, since fetch is already overridden.
It may not be needed, as it is quite straightforward, but I attach a patch for it anyway.
-
Álvaro Bautista October 9th, 2010 @ 07:00 PM
My patch was, in fact, not needed.
I'm sorry, I should have refreshed the ticket page before submitting.
-
Andrea Campi October 9th, 2010 @ 07:39 PM
- Tag changed from activesupport, hashwithindifferentaccess, params to activesupport, hashwithindifferentaccess, patch
-
Santiago Pastorino October 9th, 2010 @ 10:16 PM
- State changed from new to open
- Milestone cleared.
- Assigned user set to Santiago Pastorino
An alias is the preferred way to go here ;)
-
Repository October 10th, 2010 @ 05:08 PM
- State changed from open to resolved
(from [d80afed620dde5b9356c883ae187db2332d4c18e]) Override #store to be consistent with #[].
[#5775 state:resolved]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
http://github.com/rails/rails/commit/d80afed620dde5b9356c883ae187db... -
Repository October 10th, 2010 @ 05:08 PM
(from [61fc0f0ba0afb630efd898b5913bee32e2b0ad11]) Override #store to be consistent with #[].
[#5775 state:resolved]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
http://github.com/rails/rails/commit/61fc0f0ba0afb630efd898b5913bee... -
Ryan Bigg October 16th, 2010 @ 02:22 AM
- Tag changed from sheepskin boots, activesupport, hashwithindifferentaccess, patch to activesupport hashwithindifferentaccess patch
Automatic cleanup of spam.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 5775 HashWithIndifferentAccess should override #store [#5775 state:resolved]
- 5775 HashWithIndifferentAccess should override #store [#5775 state:resolved]