Foxify Fixtures plugin: refactor those old fixtures to make them foxy

I’ve been enjoying using foxy fixtures on new Rails projects, and wanted to start using them on some older fixture-heavy projects, but couldn’t bring myself to manually change over from id-based to foxy name-based fixtures. It would involve finding all the foreign keys in each fixture, then looking up the names of the fixtures with those ID in other fixture files, and substituting in those names. It sounded tedious and easily automated, so I went in search of a plugin or code snippet to do the work. Finding none, I wrote a plugin, ‘Foxify Fixtures.’ Install it with:

script/plugin install http://foxify-fixtures-plugin.googlecode.com/svn/trunk

Make sure your app is safely checked in to version control, or make some sort of backup in case things go awry, and run:

rake db:fixtures:foxify

The plugin was developed around two apps that I wanted to refactor to use foxy fixtures, so in all likelihood it won’t work on other apps without some tweaking. Feel free to contribute back any fixes through the plugin’s new home in Google Code: http://code.google.com/p/foxify-fixtures-plugin.

No comments yet

Leave a reply