291 Ruby 2.7 support for Rails 3.2 LTS

Updated . Posted . Visible to the public. Deprecated.

Please read our consolidated guide to modern Ruby versions instead.

Note

You can find the updated guide here.

Rails 3.2 LTS works with Ruby 1.8.7, 1.9.3, 2.3, 2.5, and 2.7. "Support" means that upgrading a Rails 3.2 application to Ruby 2.5 will not require Rails related monkey patches.

However, upgrading will still require some effort for the majority of Rails 3.2 applications, since your own code as well as some third-party gems might have compatibility issues. This is especially
true if you upgrade from Ruby 1.x. You should only attempt this as a somewhat experienced Ruby developer, and only if you have a good automatic test suite, or if you're confident that you can manually test your application.

Upgrade workflow overview

  1. Upgrade to the latest version of Rails 3.2 LTS.
  2. Upgrade your Ruby version. If you were still on Ruby 1.x, you could consider switching to Ruby 2.3 as an intermediate step.
  3. Run rails console and fix all errors. See below on how to fix common errors.
  4. Run rails server and fix all errors until a page renders.
  5. Run tests and fix remaining errors.

Rubygems

We recommend upgrading your RubyGems version to a modern 2.x version. This requires you to use bundler to manage your gems Show archive.org snapshot . Please see our RubyGems guide for additional details.

Third-party gems

Your application will probably depend on a bunch of other gems, and some of those might be incompatible with newer Rubies. The most common case are gems with native extensions that no longer compile.

You will have to check, whether these gems have an updated compatible version, can be removed, might be fixed with a monkey-patch, or have to be replaced.

An incomplete list of known incompatibilities:

  • date-performance -> remove this, no longer necessary
  • fastercsv -> no longer required, Ruby now has builtin CSV
  • mysql -> no longer compiles on Ruby 2.5, see below
  • therubyracer -> version 0.12.3 (with libv8 3.16.14.15) seems to work

Mysql

The mysql gem does no longer work on Ruby 2.5. Instead, use mysql2, in a 0.3.x version (< 0.4 in your Gemfile should do).

mysql2 is mostly a drop in replacement for mysql. The main API difference is that you might get casted values (i.e. Time objects instead of strings) when you use some low-level methods of ActiveRecord, such as select_values.

Common errors when upgrading

If you attempt an upgrade from a Ruby 1.x version, you might find some additional pointers in the corresponding section of the Rails 2.3 upgrade guide.

The main issue when upgrading to Ruby 2.5 is that there Fixnum and Bignum are deprecated and replaced by a unified Integer class. This mostly only causes deprecation warnings, but not errors, since Fixnum resolves to Integer internally.

If a third-party gem uses Fixnum and you want to remove the deprecation errors, you can often manually define a Fixnum class in the gems namespace. For example, we've added the following initializer to one of our projects:

# config/initializer/fixnum_deprecation_fixes.rb

# will_paginate
WillPaginate::Fixnum = Integer
BootstrapPagination::Fixnum = Integer

# axlsx
Axlsx::Fixnum = Integer
Tobias Kraze
Last edit
Tobias Kraze
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to Rails LTS documentation (2019-01-21 16:48)