The Complete Guide to Rails Shims

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 opens a new window , 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.

Rails 5.0

record_tag_helper opens a new window (See changes opens a new window )

content_tag_for and 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.

rails-controller-testing opens a new window (See changes opens a new window )

assigns and 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 opens a new window (See changes opens a new window )

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.

Rails 4.2

responders opens a new window (See changes opens a new window )

respond_with and respond_to methods were extracted to the responders gem.

rails-deprecated_sanitizer opens a new window (See changes opens a new window )

The HTML Sanitizer logic was reimplemented, but to keep using the old behavior you can use the rails-deprecated_sanitizer gem.

rails-deprecated_sanitizer is supported only for Rails 4.2.

rails-dom-testing opens a new window

The 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 rails-dom-testing gem.

Rails 4.1

activesupport-json_encoder opens a new window

Removed support for the encode_json hook used for encoding custom objects into JSON. This feature was extracted into the activesupport-json_encoder gem.

Deprecated ActiveSupport.encode_big_decimal_as_string and ActiveSupport::JSON::Encoding::CircularReferenceError. These features were extracted into the activesupport-json_encoder gem.

Changes:

Rails 4.0

protected_attributes opens a new window (See changes opens a new window )

This gem was supported by the Rails team until the release of Rails 5.0. We created a gem (rails_upgrader opens a new window ) to make the migration to Strong Parameters easier. We also wrote a dedicated article on that: The Complete Guide to Migrate to Strong Parameters opens a new window .

activeresource opens a new window (See changes opens a new window )

rails-observers opens a new window (See changes opens a new window )

actionpack-action_caching opens a new window (See changes opens a new window )

actionpack-page_caching opens a new window (See changes opens a new window )

sprockets-rails opens a new window (See changes opens a new window )

activerecord-session_store opens a new window (See changes opens a new window )

activerecord-deprecated_finders opens a new window

rails-perftest opens a new window

actionpack-xml_parser opens a new window

Rails 3.1

auto_link was removed from Rails and extracted into the rails_autolink gem.

Rails 3.0

mail opens a new window

All delivery methods from Action Mailer were abstracted out to the mail gem.

dynamic_form opens a new window

Helper methods like error_message_on and error_messages_for were extracted into the dynamic_form gem.

Resources

Official Rails Guides: https://guides.rubyonrails.org opens a new window

Conclusion

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 opens a new window .

Get the book