Skip to content

Instantly share code, notes, and snippets.

@kechol
Created March 12, 2015 14:43
Show Gist options
  • Save kechol/326d0150a8e159b58b71 to your computer and use it in GitHub Desktop.
Save kechol/326d0150a8e159b58b71 to your computer and use it in GitHub Desktop.
simple data
require 'yaml'
yaml = YAML.load_file("#{Rails.root}/db/seeds.yml")
yaml.each do |model_str, data|
model = model_str.capitalize.constantize
data.each do |id, row|
q = model.find_or_initialize_by id: id
q.update row
end
end
Foo:
1:
foo: bar
2:
foo: baz
Bar:
1:
bar: baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment