Search code examples
updatesruby-on-rails-2ruby-on-rails-4.2

How to update from Ruby on Rails 2.3.18 to 4.2.4 (latest)?


I want to update a huge Ruby on Rails v2.3.18 application to Rails v4.2.4 (latest).

After doing some research, I've came up with:

  • After Rails 2.3.18 (March 18, 2013), a total of 195 versions have been released until Rails 4.2.4 (August 24, 2015)
    • in which 92 are stable releases
    • and 2 major releases
    • 775 files changed
    • 909 commits

Our application runs Ruby on Rails 2.3.18 on Ruby 2.1.5.

  • Ruby should also be updated from this version to 2.2.x ?
  • Are there any individuals who achieved or tried this "leap of faith" and succeeded ?
  • Where should I start from in order to achieve my goal?
  • What is the basic flow of updating any Ruby on Rails application?

Solution

  • I have also been pondering this issue with some 5 year old projects - do I keep using rails 2.3.18 LTS https://railslts.com/ , or migrate to rails 4.2, knowing that I will then need to look at annually/biannually updating the rails version. I suspect I will be more succesful in doing a selective replacement as new functionality is developed.

    Anyway, the information I found seems to indicate it is a long step by step process:

    This post may be of help - https://groups.google.com/d/msg/rubyonrails-talk/y0q1fc8N_GU/H2xOsy2mYpwJ

    In it Rob Biedenharn suggests

    • update to rails-2.3.18 There's really no reason not to and PLENTY of good reasons that you should have done this already. 2.3.9 (2010-09-04) was the version that first gave deprecation warnings for the upgrade to rails-3.0 2.3.18 (2013-03-18) was the last releast in the 2.3 line and contains fixes for at least 10 vulnerabilities (some of them quite serious!)

    • get all your tests to pass (if you don't have tests, you'd better have faith) • address all the deprecation warnings

    • don't upgrade ruby yet https://developer.uservoice.com/blog/2012/03/04/how-to-upgrade-a-rails-2-3-app-to-ruby-1-9-3/ But you might have to upgrade to ruby-1.8.7 as rails-3.0 doesn't officially support 1.8.6)

    Oh, and I took a look at http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html as suggested by Jason Fleetwood-Boldt and that has a MUCH more detailed walk though the upgrade process from 3.0 to 4.1. But if you don't have time to go and look at that yourself, then perhaps I've given you enough with which to weigh the upgrade v. rewrite paths.

    • upgrade to rails-3.0.0 (perhaps even directly to rails-3.0.20) • get all your tests to pass

    • upgrade to ruby-1.9.2 (or perhaps even ruby-1.9.3) • get all your tests to pass

    • upgrade to rails-3.1.12 (last of the rails-3.1 line) This might not strictly be required, but 3.1 introduced the Asset Pipeline and also made jQuery the default JavaScript framework. If you have much use of Prototype or Scriptaculous in your application, it would probably be a good idea to convert that to jQuery (and get https://github.com/rails/jquery-ujs) • get all your tests to pass

    • upgrade to rails-3.2.19 • get all your tests to pass

    • upgrade to ruby-2.1.2 (there's probably no reason to just use 2.0 at this point) • get all your tests to pass

    • upgrade to rails-4.0.8 • get all your tests to pass

    • upgrade to rails-4.1.4 • cope with the new secrets.yml file • get all your tests to pass

    • take a vacation

    Seriously, there's a lot to do if you really want to go the upgrade route. I haven't even mentioned any of the issues that you're almost certain to encounter with gems that cease to function with newer versions of Rails or even newer Rubies. I'd recommend that you very seriously consider "refreshing" the application as a simpler way to bring the application onto a current, supported RoR stack.