Skip to content

Instantly share code, notes, and snippets.

@odinsbane
Created February 18, 2018 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odinsbane/f7ba106e5d7328a03f4b01f9a3c6af24 to your computer and use it in GitHub Desktop.
Save odinsbane/f7ba106e5d7328a03f4b01f9a3c6af24 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'yaml'
require 'set'
task :loadsources => :environment do
relations = YAML.load_file("db/built-sources.yml");
Source.all.each do |viejo|
viejo.destroy
end
relations.each do |source|
s = Source.new
source[:basic_questions].each do |cat_num|
question=BasicQuestion.where(:category=>cat_num[0]).where(:number=>cat_num[1]).first
s.basic_questions.push(question)
end
s.content = source[:content]
s.save
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment