Upgrading to Rails 1.2
Making the switch
The Rails team didn't make the switch to Rails 1.2 very easy. I've spent a few hours getting this site ready to deploy as Rails 1.2.2 (the latest version at time of writing). As I was also using Rails Engines it was even harder than your average upgrade.
It didn't help that the sparse documentation on upgrading is inaccurate.
Update
Upgrade everything. Yes, do it. But wait! Only do it on your development box. As this server has several Rails projects, and as I only wanted to upgrade one of them, I froze Rails 1.2.2 into this application under vendor/rails. If you're going to do this, do it on your development box, and then upload your changes to your live server - i.e. don't upgrade Rails on your live box!
To upgrade Rails:
sudo gem update rails --include-dependencies
To freeze the version inside an application, type:
rake rails:freeze:edge TAG=rel_1-2-2
Note that the stable version of mongrel 1.1 is out. If you are friends with mongrel (and you should be):
sudo gem update mongrel --include-dependencies
Routes
One of the big gotchas for this site was routes. Because I use dynamic URLs that include commas and dots and so forth, depending on the title of a blog article, I found I could no longer retrieve articles by clicking their old links. I made the following change.
From:
map.connect '/code/:title', :controller => 'code', :action => 'show'
To:
map.connect '/code/:title', :controller => 'code', :action => 'show', :requirements => { :title => /.*/ }
As you can see, the regexp in :requirements allows you to restrict or enable access to certain ':title's.
Upgrading Engines
Upgrading engines was a pain.
Firstly, you must upgrade to Rails Engines Version 1.2.
This means uninstalling your vendor/plugins/engines plugin and reinstalling the latest engines plugin in their trunk svn repository. After that, take the following steps. There may well be more for you.
engine_schema_info deprecation
That's right. The table previously known as 'engine_schema_info' should now be called 'plugin_schema_info'. Don't pay attention to the lies in the engines documentation - it tells you to change a table called 'engine_schema' to 'plugin_schema'. This table doesn't exist.
I wrote a migration that does a drop_table on plugin_schema_info (as I wasn't using it before), then does a rename_table on engine_schema_info. I'm sure you can work out a solution that best fits you.
init_engine.rb => init.rb
Rename your init_engine.rb files to init.rb. I removed all references to versions while I was at it, as I didn't need to declare versions for my wholly unpublished engines.
Configs
If you use engine config helpers, you need to get rid of them. They've been removed in favour of using attr_accessors, as the documentation says, or as I prefer, mattr_accessors, since the engines require a module by default in init.rb.
You must then remove occurrences within your config/environment.rb of:
module YourEngine
config :name_of_config, 'something'
end
And replace them with:
YourEngine.name_of_config = 'something'
Tests
I removed lines 3-13 from the standard generated test/test_helper.rb within all engines. You basically need to remove all references to EngineName.config. I haven't been able to successfully run all my previous tests just yet.
end_form_tag
Now a deprecated helper in favour of the block-taking form_for helper, all it ever did was this:
</form>
So for now, I've replaced all occurences of end_form_tag with the raw HTML, to stop whiny warnings.
Helpers
Engine helpers that were previously included within app/helpers/application_helper.rb should now be required from your engine's init.rb. What I prefer to do is edit the vendor/plugins/my_engine/lib/my_engine.rb and simply stick the following in there:
class ActionView::Base
def stuff
'some html'
end
end
That's your lot
If you got this far without sleeping, you're probably a Rails programmer. Good luck to you sir. Add comments if you find any more useful tips for upgrading.
Comments
“I recently got a problem on another box with missing readline. See http://ubuntuforums.org/showthread.php?t=169891”