The Complete Guide to Rails Shims
When upgrading a Rails application, you might find that sometimes functionality is extracted from Rails and moved into a new gem. These gems are called shims, and they will basically allow you to keep using an old functionality, once the core API takes that out. You can also find shims in form of monkey patches. In this case it’s functionality that you develop to make your migration easier.
In this article I will list some of the functionality of past versions of Rails that was extracted into gems.
div_for were removed in favor of just using
content_tag. To continue using the older methods, add the
record_tag_helper gem to your Gemfile.
assert_template were extracted to the
rails-controller-testing gem. To continue using these methods, you will need this gem in your Gemfile.
ActiveModel::Serializers::Xml was extracted from Rails to the
activemodel-serializers-xml gem. To continue using XML serialization, add gem
activemodel-serializers-xml to your Gemfile.
respond_to methods were extracted to the
The HTML Sanitizer logic was reimplemented, but to keep using the old behavior you can use the
rails-deprecated_sanitizer is supported only for Rails 4.2.
TagAssertions module (containing methods such as
assert_tag), was deprecated in favor of the
assert_select methods from the
SelectorAssertions module, which was extracted into the
Removed support for the
encode_json hook used for encoding custom objects into JSON. This feature was extracted into the
ActiveSupport::JSON::Encoding::CircularReferenceError. These features were extracted into the
This gem was supported by the Rails team until the release of Rails 5.0. We created a gem (rails_upgrader) to make the migration to Strong Parameters easier. We also wrote a dedicated article on that: The Complete Guide to Migrate to Strong Parameters.
auto_link was removed from Rails and extracted into the
All delivery methods from Action Mailer were abstracted out to the
Helper methods like
error_messages_for were extracted into the
Official Rails Guides: https://guides.rubyonrails.org
I hope this list of gems comes in handy when upgrading your Rails application. Let me know if I missed any important ones.
Finally, if you want more details on how to upgrade each version of Rails, you can download our free eBook: The Complete Guide to Upgrade Rails.