Upgrading to Rails 2.0
Here’s how one upgrades to Rails 2.0.
Upgrading the gem
This depends on what version of Rails currently running.
If you’re on any version prior to 1.2.6
Upgrade your app to 1.2.6. Instead of messing around with installing/upgrading gems, freeze a version of 1.2.6 to your app. Freezing means putting the entire rails framework in vendor/rails, using that instead of the installed gem. It requires that Subversion is installed on your system.
rake rails:freeze:edge TAG=rel_1-2-6
Then move on to the next section.
When you’re on 1.2.6
Make sure your app runs smoothly with this version, and that you don’t get any deprecation warnings or errors whatsoever.
If you have written tests, just run them. If everything passes, you’re probably O.K. If you didn’t write tests, you’ll have to browse through your entire app by hand (and hope you don’t miss anything). Have fun.
If no errors occurred, move on.
Upgrading the actual gem.
To upgrade the Rails gem, all you need to do is this:
gem install rails -y
The -y means that it will include all dependencies, which is ActionController, ActiveRecord and so on.
The tricky part!
This is when people get confused. When the server boots, you’ll either get the error message from hell, or you’ll get it when you try to access stuff in your app.
Upgrading the generated files
When the app was generated with the rails command back in the 1.x days, it generated a bunch of directories and files (doh). These files are, however, still 1.x files, and needs to be 2.0-ed.
To upgrade the Rails “skeleton” to 2.0, re-run the rails-command on the app. This will overwrite the 1.x files to the 2.0 files.
First, make backups of any changed files, which most likely includes app/controllers/application.rb, config/environment.rb and so on. Then, run the command.
(Yes, the dot (.) is there, and has a space between itself an the rails command.)
It’ll start working, and then ask what to do as soon as it finds a file that already exists (which it obviously will pretty early on). A simple a is a good answer here, as that will have it overwrite all the existing files with new 2.0 files, no questions asked. At least it was polite enough to ask the first time, yah!
So, with that done, a new config/initializers directory has been added, and the app is using the new 2.0 cookie session store, which is much more efficient than the file store 1.x used by default.
Re-adding the old stuff
This step blanked out the skeleton. Manually merge the stuff that was in them back to the newly generated files. As in, don’t copy everything that was in application.rb into the newly generated application.rb. That would be pointless, as the defaults set by 2.0 would have been removed. Make sure the stuff that’s in there stays, and append the old stuff – don’t replace it with the old stuff. Yah.
And then, have fun with errors
This guide sucks, and probably won’t work for you. Have fun!
Questions or comments?