I'm working on a Rails 2.3.14 project, which uses 0.6.0 of the i18n gem and 2.3.14 of the ActiveSupport gem. Both of these define a Hash#slice
method (i18n's; ActiveSupport's), but they function differently: the i18n version uses Hash#fetch
, and so raises an i18n/core_ext/hash.rb:4:in 'fetch': key not found (IndexError)
exception if any requested key is missing, while the ActiveSupport version happily ignores missing keys, and the rest of ActiveSupport depends on that happy ignoring.
In my app, the i18n version is loading first (because, incidentally, faker is loading it as a dependency), so when ActiveSupport tries to depend on the ignore-missing-keys behavior I get the exception.
Is there a way to tell Rails to load ActiveSupport before faker and i18n?
You could also monkey patch the Hash class after the gems are required. You could just paste the contents of ActiveSupport's hash/slice.rb into your app somewhere. The URL can be found here:
https://github.com/lifo/docrails/blob/master/activesupport/lib/active_support/core_ext/hash/slice.rb
That would override the definitions from the gems though, so YMMV.