Created
December 1, 2008 10:03
-
-
Save JakubOboza/30696 to your computer and use it in GitHub Desktop.
Using yaml dump with Active Record
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Comatose::Page < ActiveRecord::Base | |
end | |
desc "load pages" | |
task :load_pages_to_db => :environment do | |
YAML::add_private_type("Comatose::Page") do |type, value| | |
Comatose::Page.new(value) | |
end | |
dump_yaml = 'comatose_dump.yaml' | |
@pages = YAML::load_file( dump_yaml ) | |
@pages.each do |p| | |
Comatose::Page.create(p.attributes) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment