-1

I am working on a very old rails project. The gemfile is like this:

source 'http://rubygems.org'

gem 'rails', '2.3.17'

gem 'rake', '0.8.7'
gem 'rdoc', '3.6.1'

gem 'mysql', '2.8.1'

gem 'roo', '1.9.7'
gem 'rubyzip', '0.9.4'
gem 'pdf-writer', '1.1.8'

gem 'prawn', '0.12.0'

gem 'sendmail'

gem 'htmldoc', '0.2.3'

The ruby version is 1.8.7

What is the easy way to upgrade this rails app ? Can I just change the version of each gem to the latest one and expect it will work fine?

Kelvin Tan
  • 982
  • 1
  • 12
  • 33
  • 11
    No you obviously can’t. Even more, expect almost everything will require a manual intervention since many interfaces were changed since `2.3.17`. I would suggest going step by step (2.3 ⇒ 3.2 ⇒ 4.1 ⇒ 5.1) and fixing problems on each subsequent step. – Aleksei Matiushkin Sep 05 '17 at 08:37
  • 2
    Rails 2.3 to 5.x and Ruby 1.8 to 2.x? If the project is small, you should consider rebuilding it from scratch. – Stefan Sep 05 '17 at 09:30
  • In addition to what @mudasobwa said, start by covering your current application with tests. Once you have maximum coverage, you can begin changing versions. Version changes and manual interventions usually break things and it is of your interest to know beforehand what needs to be fixed. Tip: use Simplecov gem to check coverage. – rodsoars Sep 05 '17 at 12:51

1 Answers1

0

There is no easy way. Before You start upgrade you must add tests to be sure that application will still work after upgrade. Then I recommend to change gem description to following syntax: gem 'mysql', '~> 2.8.1' it tells bundler to update only last number of version of gem.

Then repeat following step

  • change rails version to next
  • bundle update rails
  • corrected conflicted gem version by hands
  • bundle update
Piotr Galas
  • 4,518
  • 2
  • 21
  • 30