Upgrading from Rails 2.3.8 to 4.0
Asked Answered
C

2

22

I am running an application on Rails 2.3.8. I am planning to upgrade it to Rails 4.0 (which is in RC). What will be the easiest way for me to do this? Do I need to first upgrade to Rails 3.x?

Note: in my current implementation, I am using starling and ferret; as part of upgrade I am also considering to move to sidekiq and sunspot

Calyptrogen answered 17/6, 2013 at 6:13 Comment(4)
"Do I need to first upgrade to Rails 3.x" - that depends on your threshold for acceptable pain :). In general, breaking up large changes into smaller incremental changes is a recommended approach.Housewarming
Also, you should certainly try to upgrade to the latest 2.3.x before moving to either 3.x or 4.Housewarming
you will most probably need to upgrade your ruby as wellDoralynne
I really hope you have a decent test coverage before you dive into that. Even a non-decent coverage will help keep your heart rate within a healthy range.Shebeen
D
51

This is a multi-step process, and depending on the size of your application, it can take a long time. At each step, you'll want to test your application for bugs and problems and broken gems (because they are most certainly going to crop up). I have included links for the most complicated steps. Here is the path of least pain:

Update to Rails 2.3.18.

Update to Ruby 1.9.3.

Update to Rails 3.0.

Update to Rails 3.1.

Update to Rails 3.2.latest.

Update to Ruby 2.0.latest.

Update to Rails 4.0.

Update from Rails 4.0 to Rails 4.1.

Update from Rails 4.1 to Rails 4.2.

Update from Rails 4.2 to Rails 5.0.

Update from Rails 5.0 to Rails 5.1.

Bonus: If you have a large application, this is going to take a long time. If you have a large team, long-running branches become a huge headache because of recurring merge conflicts. One strategy for mitigating this is to dual boot your application with both versions of Rails so that you can have the new version running on your master branch, rather than on a long-running branch of its own.

Durarte answered 14/7, 2013 at 16:47 Comment(6)
Hi. Just out of interest, why do you upgrade to Ruby 1.9.3 before upgrading to Rails 3.0? Rails 2.3 doesn't support Ruby 1.9 out of the box, whereas Rails 3 does, so does this approach create additional work to make Rails 2.3 work with Ruby 1.9?Murky
Good point. You can definitely upgrade to Rails 3 before moving to Ruby 1.9. In our case, we had a large application, and moving from Ruby 1.8.7 to 1.9 was far less work than moving from Rails 2.3 to 3.0. It took us a couple months to get on 1.9, but over a year to get on 3.0. So, we went with the easier update first to give us the performance benefits and gem compatibility of Ruby 1.9 sooner.Durarte
OK, interesting. I had wondered if going to ruby 1.9 first might be the right thing to do for performance reasons - hadn't considered gem compatibility. I'll try the rails upgrade first and see how I get on.Murky
To follow up here, I upgraded the whole way through to latest Rails 3.2 under Ruby 1.8.7, but I found the performance was so bad that I had to upgrade to Ruby 1.9.3 anyway before going to production. So I would recommend upgrading to Rails 3.0 first, then Ruby 1.9.3 (for gem compatibility and performance benefits mentioned by @aaron), and then rails 3.1, 3.2.Murky
Links to guide lead to 404'sSierrasiesser
Thanks for the heads-up. I've updated the two dead links to use the Wayback Machine so they can be accessed again.Durarte
F
2

Aaron Gray's answer is very useful, but sometimes it's very difficult after upgrading to find the differences between rails version in the code. I mean, many times after upgrading something doesn't work. Maybe could be some changes in the file or some file could be added or removed in newer version. There is a nice tool, how you can find out all differences between version and compare them. It's on Rails differences and could be very helpful to discover some potential mistakes and bugs.

Flinger answered 22/10, 2014 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.