Data modeling in Ruby with ActiveRecord
I had a little problem to solve the other day where I wanted to work up a database from scratch, and then transfer data from an existing database into it. On the spur of the moment I decided to see how quickly/easily this could be done in Ruby. Long story short, the thing I learned (obvious in hindsight) is that:
require 'rubygems' require_gem 'activerecord'
is all you need to get access to all that ActiveRecord modelling goodness outside of the Rails framework proper (assuming Rails is installed on your system). The real pay-off is being able to use migrations to develop the database schema. I wrote a simple script to call the conventional ‘up’ and ‘down’ methods of my migration classes, mostly because I hadn’t appreciated how simple it would be configure Rake for this purpose outside of a Rails application. I’ll know next time. When I think of the hours I’ve spent with various ORM frameworks in Java….
comments powered by Disqus