Thursday, May 10, 2007

Dump a table to YAML dump

from DZone Snippets: rails code by rohan_kini (ROhan Kini)


//Dump a table to YAML dump


require 'yaml'

task :dump_fixtures => :environment do |t|
File.open('dump.yml', "w") do |f|
js.each do |j|
f.print YAML.dump ({"record_#{j.id}" => j.attributes})
end
end
end

No comments :