Commit da778d6c6e848f646a24f541835d22493e6ba638
1 parent
81d282bd
Exists in
master
and in
1 other branch
Rake task for populating noman parks
Conflicts: lib/tasks/prune_db.rake
Showing
1 changed file
with
24 additions
and
0 deletions
Show diff stats
lib/tasks/prune_db.rake
@@ -150,4 +150,28 @@ namespace :prune_db do | @@ -150,4 +150,28 @@ namespace :prune_db do | ||
150 | puts " #{voter_count} have inconsistent voters" | 150 | puts " #{voter_count} have inconsistent voters" |
151 | end | 151 | end |
152 | 152 | ||
153 | + #call this by doing rake prune_db:populate_seed_ideas['blahblah',questionnum], where blahblah is the filename | ||
154 | + task(:populate_seed_ideas, :args1, :args2, :needs => :environment) do | task, arguments| | ||
155 | + filename = arguments[:args1] | ||
156 | + question_num = arguments[:args2] | ||
157 | + | ||
158 | + puts filename | ||
159 | + puts question_num | ||
160 | + | ||
161 | + q = Question.find(question_num) | ||
162 | + creator_id = q.creator_id | ||
163 | + | ||
164 | + File.open(filename, "r") do |infile| | ||
165 | + while( data= infile.gets) | ||
166 | + c = Choice.new(:creator_id => creator_id, | ||
167 | + :question_id => q.id, | ||
168 | + :active => true, | ||
169 | + :data => data.chomp) | ||
170 | + | ||
171 | + c.save | ||
172 | + end | ||
173 | + end | ||
174 | + | ||
175 | + end | ||
176 | + | ||
153 | end | 177 | end |