Hashie::Extensions::Array Leaks into actionpack
streetlogics opened this issue · 5 comments
Was updating an application's Gemfile dependencies, and after upgrading to Rails 4.2 and the latest version of Hashie (3.5.6), we started getting the following error:
undefined method `wrap' for Hashie::Extensions::Array:Module in gems/actionpack-4.2.10/lib/action_controller/metal/strong_parameters.rb:225:in `block in permit!'
This is the code there:
223: def permit!
224: each_pair do |key, value|
=> 225: Array.wrap(value).each do |v|
226: v.permit! if v.respond_to? :permit!
227: end
228: end
229:
230: @permitted = true
231: self
232: end
I'm interested in how/why Ruby is trying to use Hashie::Extensions::Array instead of Ruby's base Array class. I could probably go ahead and just monkeypatch that permit!
call to use ::Array
instead, but it seems like there should be a better solution than that. Any thoughts?
For now I've reverted to 3.4.4. since that's the last version before Hashie::Extensions::Array
was introduced.
Are you using https://github.com/Maxim-Filimonov/hashie-forbidden_attributes or anything like that? I think the class in which this is executed is a Hashie::...
class, so it looks up Array
from the Hashie namespace first. It would be interesting to construct/see a repro for this and debug how lookup happens.
Are you wrapping your ActionController::Parameters
object in a Hashie::Mash
, by chance?
Also, could you share what self
is at line 225 in your example? As dB said, a test would be ideal, but that would be a start.
Closing due to lack of information. If you're still seeing this error, please let us know.
i think this is caused by people sometimes doing this on array or hash:
Hash.send :include, Hashie::Extensions