Open jonnymacs opened 10 years ago
Conditional definition of HashWithIndifferentAccess can also be risky, if the active_support version does exist, but is or becomes incompatible with the way tpkg uses it.
Might be safer to rename the class entirely, or put it into a module to namespace it (along with other classes that may be borrowed from active_support)
The issue I came across has to do with the way rails4 casts parameters to ActionController::Parameters objects. There are some methods rails expects to exist on these objects, but the are missing if the tpkg gem is loaded
Easiest way to repro this would be to run a rails4 app that has tpkg in the Gemfile default group, then execute these steps from the rails console
The output should be
Now the tpkg gem should not get loaded with rails. It is / was getting loaded b/c it is / was part of the default group in bundler in our application. We no longer include tpkg in the default bundler group, which resolves the issue.
But it still seems risky to define HashWithIndifferentAccess class in tpkg in the event that it's already defined by someone else.
Perhaps there is a way to conditionally create HashWithIndifferentAccess if it's not already defined by someone else (like ActiveSupport)?
some references https://github.com/rails/strong_parameters https://github.com/rails/strong_parameters/issues/140