Upgrading Rails apps has become a lot easier over the years. Most of the time you can simply update your Gemfile, try to
bundle and make sure all your existing Gems are compatible with the new version, if not run
bundle update <gemname> on each of them one at a time until all dependencies resolve and then finally run
rake rails:update, letting Rails make sure you’re setup properly for a new version.
The problem is that new versions of Rails often come with new default configrations inside of the following files and directories:
And there’s always a lot to learn from those new default configuration. Even if we should, we don’t often catch all the subtle changes and improvements made to those Rails defaults. The result is that problems arising from upgrading to a new Rails version often come from not knowing about these new defaults.
To address this, Jacob Swanner had written a blog post for the Envy Labs blog last year offering useful Git diffs for the modified files between several different Betas and Release Candidates of Rails 3.1 and the 3.1.1 final release.
Dwayne Henderson took it one step further by writting a useful Bash script that automated this process between a selected “old version” and the newest version of Rails available. Making it a lot less painless to get relevant information for the versions you care about.
Refining the Solution
His script didn’t really work on my system so I took it as an opportunity to improve it a bit and despite my serious illiteracy when it comes to Bash scripting, I came up with a version that:
- uses Bundler instead of RubyGems to create a version-specific skeleton Rails app, it’s much faster and doesn’t mess with your system Rubies or RVM Gemsets
- allows you to set which
new_versionof Rails you want to compare with the
new_versionis left blank it compares against the latest stable version of Rails
- provides descriptive colorized output for all actions being done by the script
- outputs the resulting Git diffs to your system’s default
$EDITORinstead of less
Download the script here and make sure you save it as a
Here’s an example diff from Rails 3.1.4 to 3.2.6.
I would love it if someone could help me test this script to make sure it works across environments and not just on my local machine, since I use ZSH and OS X I don’t know if this will act the same elsewhere.
Better yet, Jacob mentioned it would be a great idea to directly ping the Rails repo on GitHub for specific version tags to perform this without even needing to install new Rails versions locally. He’s working on a solution for that.
Finally, I think it would make sense to create a web service that outputs differences between blank slate Rails apps when you query it like this: