Upgrading from Rails 2.3.8 to 4.0

2019-01-10 10:24发布

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

2条回答
闹够了就滚
2楼-- · 2019-01-10 10:51

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.

查看更多
老娘就宠你
3楼-- · 2019-01-10 10:55

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.

查看更多
登录 后发表回答