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.
Rails 5.0
record_tag_helper
(See changes )
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
(See changes )
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
(See changes )
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
(See changes )
respond_with
and respond_to
methods were extracted to the responders
gem.
rails-deprecated_sanitizer
(See changes )
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
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
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:
- https://github.com/rails/rails/pull/12183
- https://github.com/rails/rails/pull/12785
- https://github.com/rails/rails/pull/13060
Rails 4.0
protected_attributes
(See changes )
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 .
activeresource
(See changes )
rails-observers
(See changes )
actionpack-action_caching
(See changes )
actionpack-page_caching
(See changes )
sprockets-rails
(See changes )
activerecord-session_store
(See changes )
activerecord-deprecated_finders
rails-perftest
actionpack-xml_parser
Rails 3.1
rails_autolink
auto_link
was removed from Rails and extracted into the rails_autolink
gem.
Rails 3.0
mail
All delivery methods from Action Mailer were abstracted out to the mail
gem.
dynamic_form
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
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 .