27 cards
Posted almost 4 years ago. Visible to the public.

Fixing 'uninitialized constant / undefined class/module ActionDispatch::Http::ParamsHashWithIndifferentAccess' when migrating away from Rails LTS

Rails 2.3 and 3.2 LTS use ActionDispatch::Http::ParamsHashWithIndifferentAccess to represent params hashes, similar to Rails 5's ActionController::Parameters.

If you serialize data in Rails LTS, then upgrade to other Rails versions (such as Rails 5) and then try to deserialize the data, you might run into an error

Copy
uninitialized constant ActionDispatch::Http::ParamsHashWithIndifferentAccess

or

Copy
undefined class/module ActionDispatch::Http::ParamsHashWithIndifferentAccess

To fix this, add the following line to an initializer in your Rails 5 app:

Copy
ActionDispatch::Http::ParamsHashWithIndifferentAccess = ActionController::Parameters

You can do this either temporarily in order to migrate all serialized data once, or keep it permanently.

Rails 4.2 LTS already does this for you (starting with Rails 4.2.11.11 LTS).

Your development team has a full backlog of feature requests, chores and refactoring coupled with deadlines? We are familiar with that. With our "DevOps as a Service" offering, we support developer teams with infrastructure and operations expertise.

Owner of this card:

Avatar
Tobias Kraze
Last edit:
over 3 years ago
by Tobias Kraze
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
This website uses short-lived cookies to improve usability.
Accept or learn more