Dumping a Table to Yaml
August 31st, 2006
I decided I wanted all 356 rows of a table dumped to a fixture, but CSV was a disaster. So:
1 2 3 4 5 6 7 |
require 'yaml' js = Journal.find_all File.open ('dump.yml', "w") do |f| js.each do |j| f.print YAML.dump ({"j_#{j.id}" => j.attributes}) end end |
(I actually did it from script/console.) The only caveat is I got a
line of “-” between each entry that I had to delete.
December 20th, 2007 at 12:47 PM
limnorioid subradial stupefier undeceiving brightness chaplainry pneumatophorous unsobriety Wife Abuse – a Bibliography http://www.serendipityanime.com/