Building ActiveRecord database interface from the ground up