DEV Community

Milos
Milos

Posted on

Ruby on Rails 4.2.X upgrade issue with meta_request — undefined method normalize_key

You may find yourself in need to migrate from RoR 4.2.X to the latest version, and that can be quite a task. Facing the same problem, I would like to point out the issue that bugged me for quite a bit, and that is gem meta_request.

Now if you are not using it, this text is not for you, but if you are, you might find this post helpful.

So, initial situation: very old Ruby, very old Rails.

Next step(s): keep the Rails version, update Ruby (in this case to 2.6.0 or at least to 2.3.0)

Last step(s): update Rails to 5.0 and then to 6.0 and so on, by the book.

Updating Ruby went fine more or less, keep in mind that the Rails is still the same version, also bundle install yielded minor hiccups/errors but nothing that can’t be resolved.

But upon landing/opening home page I got

NoMethodError: undefined method normalize_key ActiveSupport::Cache::Store

Now normalize_key is Rails 5+ function, and I had 4.2.X, how the hell is that being called then?

The answer is meta_request!

Yes, bundler picked up latest possible version, since it says it is compatible with Rails(i.e. railties >= 3.0.0) and in it, meta_request on line uses normalize_key call, which is Rails 5 feature(from v5.0.0.1).

So to fix this issue just do:

gem 'meta_request', '~> 0.7.4'

until you bump your Rails to 5+.

Cheers!

Top comments (0)