diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index ec90fcc..cd2c1dd 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -15,7 +15,7 @@ class QuestionsController < InheritedResources::Base def create authenticate logger.info "vi is #{params['question']['visitor_identifier']} and local are #{params['question']['local_identifier']}. all params are #{params.inspect}" - if @question = current_user.create_question(params['question']['visitor_identifier'], :name => params['question']['name'], :local_identifier => params['question']['local_identifier'], :ideas => params['question']['ideas'].lines.to_a) + if @question = current_user.create_question(params['question']['visitor_identifier'], :name => params['question']['name'], :local_identifier => params['question']['local_identifier'], :ideas => (params['question']['ideas'].lines.to_a) rescue []) respond_to do |format| format.xml { render :xml => @question.to_xml} end diff --git a/app/models/question.rb b/app/models/question.rb index 1e20933..05e80d5 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -62,6 +62,7 @@ class Question < ActiveRecord::Base def ensure_at_least_two_choices the_ideas = (self.ideas.blank? || self.ideas.empty?) ? ['sample idea 1', 'sample idea 2'] : self.ideas + the_ideas << 'sample choice' if the_ideas.length < 2 if self.choices.empty? the_ideas.each { |choice_text| item = Item.create!({:data => choice_text, :creator => creator}) -- libgit2 0.21.2