Rails importer from Ryan Bates Railscast #396 with some tweaks (work in progress)