Topic: Issue looping
Hi this is the gist of my code
def gen_questions(*qn_array) if !questions.nil? qn_array.each do |i| self.questions.build(:question_no=>i,:answer=>"",:score=>0) self.save end end end
The problem with this code is that only 1 question is created.
How to change it in such as way that the question is created the same number of time as the number of elements in the array?