From da778d6c6e848f646a24f541835d22493e6ba638 Mon Sep 17 00:00:00 2001 From: Dhruv Kapadia Date: Thu, 22 Jul 2010 11:08:16 -0400 Subject: [PATCH] Rake task for populating noman parks --- lib/tasks/prune_db.rake | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+), 0 deletions(-) diff --git a/lib/tasks/prune_db.rake b/lib/tasks/prune_db.rake index 0d5ddba..5e90ee6 100644 --- a/lib/tasks/prune_db.rake +++ b/lib/tasks/prune_db.rake @@ -150,4 +150,28 @@ namespace :prune_db do puts " #{voter_count} have inconsistent voters" end + #call this by doing rake prune_db:populate_seed_ideas['blahblah',questionnum], where blahblah is the filename + task(:populate_seed_ideas, :args1, :args2, :needs => :environment) do | task, arguments| + filename = arguments[:args1] + question_num = arguments[:args2] + + puts filename + puts question_num + + q = Question.find(question_num) + creator_id = q.creator_id + + File.open(filename, "r") do |infile| + while( data= infile.gets) + c = Choice.new(:creator_id => creator_id, + :question_id => q.id, + :active => true, + :data => data.chomp) + + c.save + end + end + + end + end -- libgit2 0.21.2