What is the best way to keep your Rails version up to date?
The application I'm working on was started with Rails 3.0.6, I believe 3.0.7 is available and 3.1 is just around the corner.
I realis开发者_JAVA百科e 3.1 will likely have some breaking changes, requiring a proper read through of release notes etc, before attempting to update the project.
My question though, is what is considered best practice for the x.x.x updates and the x.x updates? Should they be treated differently? Barring breaking changes, is it best to create a brand new project each time and drop in the changed files?
Rich
The best way is always to specify your Rails and other Gem Versions within your Gemfile.
gem 'rails', '3.0.7'
When a new version is released you simply bump the version, bundle and run your test suite. Following the change log will allow you to assess if any changes will be required. Rails is very good at providing Deprecation warning for your code segments so you should know about a change before it happens. Hope this helps, all the best.
I have a bit of a mixed opinion on this.
On one hand, you want to be pragmatic about your upgrades and assess whether taking the time to upgrade your version of Rails will bring about any benefits for you. Sometimes this is obvious--speed improvements to slow parts of your app, improved pipelines or workflows, etc. might bring obvious gains, and you can easily justify taking the time to upgrade the app. Sometimes, it's not so obvious, and there's certainly a great number of production apps, some very well known, still running 2.3 and Ruby 1.8.7.
On the other hand, Rails is a fast-moving project, and I personally wouldn't want to sit around on a very old version. The longer you wait to upgrade, the more work you'll likely have to do to modify your app accordingly.
If you feel like it's time to upgrade, or that upgrading is a good idea, my advice to you is create a new branch in your version control system and test and profile the new version. That way, you and the rest of your team can continue working on the app in the old branches as normal, and you can get a good idea of how much work it'll take to upgrade Rails. Then, if everything goes horribly wrong, you can just delete the new branch and move on your merry way.
TL;DR
- Be pragmatic about your upgrades--assess if the upgrade will bring any real, measurable benefit to your app or your team
- Always test and profile new versions of Rails (or any other dependency!)
精彩评论