Skip to content

Instantly share code, notes, and snippets.

@dmshvetsov
Last active June 1, 2019 15:29
Show Gist options
  • Save dmshvetsov/6317604 to your computer and use it in GitHub Desktop.
Save dmshvetsov/6317604 to your computer and use it in GitHub Desktop.
How to seed your database with JSON/YAML. Source http://snippets.aktagon.com
json = ActiveSupport::JSON.decode(File.read('db/seeds/countries.json'))
json.each do |a|
Country.create!(a['country'], without_protection: true)
end
@Baw25
Copy link

Baw25 commented Sep 23, 2016

q2w3e45iuikujjygtfdfgfdrewsde3wwwrewq

@antmelnyk
Copy link

It helped a lot, thanks!

@DazDotOne
Copy link

Thanks for this. Helped a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment