Sarun Sermsuwan
Sarun Sermsuwan

Reputation: 3818

Which version of rails to use

what is the best when it come to choosing what version of rails to use in your development?

I wanted to upgrade to the newest version for the new features, but in many cases chances were high that my existing code would be broken, and a lot of extra time definitely needed to spend fixing it. Should I stick with the current version of rails I'm using? or heading for upgrade?

Any advice or guideline would be really appreciated.

Upvotes: 0

Views: 136

Answers (2)

mliebelt
mliebelt

Reputation: 15525

I think you have to check carefully when and how to upgrade. Here are some hints that may help in the upgrade process:

  • Patch versions (like upgrade from Rails 3.1.0 to Rails 3.1.1) were normally no problem at all. Upgrade whenever possible, normally you don't have to change anything. Sometimes you have to check if other Gems as well should be upgraded, read the release notes, they give (sometimes) hints about that.
  • Minor versions (like upgrade from Rails 3.0.9 to Rails 3.1.0) come with new features and non-compatible changes. In the release notes, you will find information what has changed and has to be proven before hand. As an example, look at Ryan Bates railscast "Upgrading to Rails 3.1.0". You normally have to do the following steps:

    • Upgrade to the last patch version before.
    • Look at the deprecated log messages. These are the ones that may break after the upgrade.
    • Tag your current application, or branch to be sure to not destroy anything by the upgrade.
    • Do the upgrade up to the point you are sure most needed features work again.
    • Merge back your changes, and continue with the upgrade

    (Have done that the last few days for an application I have upgrade from Rails 1.2 to 2.0 up to 2.3.8 to 3.0.0 up to 3.0.9, and now 3.1.1.)

  • Major version upgrades are even more difficult. You have to ensure that you have enough time and resources to check all the minor glitches you may have. Most of the time, there were resources available by the Rails team that help do the upgrade, like the Rails upgrade helper or the 3 railscast "Upgrading to Rails 3".

In any case, you should at least check if the main Gems you are using (additional to the normal Rails gems) are compatible with the version you want to migrate to. This may be tricky, but sometimes, the information is available.

My experience is, that Major upgrades take time, and if you don't have it, don't do the upgrade. Minor upgrades take some time, and depending on the change (assets in Rails 3.1) come with a price tag, which is sometimes, not all of the times, worth it. Patch upgrades are painless and should be done at will.

Upvotes: 0

Marek Tihkan
Marek Tihkan

Reputation: 1914

It is useful to always upgrade, because new gems might not support older versions of Rails and you wil get new features from Rails which could reduce code. You can do it step by step, fixing time to time code that will break in newer version of Rails. It more like continuous refactoring.

Upvotes: 2

Related Questions