Created
February 18, 2018 21:21
-
-
Save odinsbane/f7ba106e5d7328a03f4b01f9a3c6af24 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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