Commit 5042ef84cc20260eba87a9028c77f11a0a0304aa

Authored by Pius Uzamere
1 parent 9ce7b498

stop catching errors in idea creation and improve logging

app/controllers/questions_controller.rb
@@ -20,7 +20,7 @@ class QuestionsController < InheritedResources::Base @@ -20,7 +20,7 @@ class QuestionsController < InheritedResources::Base
20 def create 20 def create
21 authenticate 21 authenticate
22 logger.info "vi is #{params['question']['visitor_identifier']} and local are #{params['question']['local_identifier']}. all params are #{params.inspect}" 22 logger.info "vi is #{params['question']['visitor_identifier']} and local are #{params['question']['local_identifier']}. all params are #{params.inspect}"
23 - if @question = current_user.create_question(params['question']['visitor_identifier'], :name => params['question']['name'], :local_identifier => params['question']['local_identifier'], :ideas => begin (params['question']['ideas'].lines.to_a.delete_if? {|i| i.blank?}) rescue [] end) 23 + 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.delete_if? {|i| i.blank?}))
24 respond_to do |format| 24 respond_to do |format|
25 format.xml { render :xml => @question.to_xml} 25 format.xml { render :xml => @question.to_xml}
26 end 26 end
app/models/user.rb
@@ -10,7 +10,7 @@ class User < ActiveRecord::Base @@ -10,7 +10,7 @@ class User < ActiveRecord::Base
10 end 10 end
11 11
12 def create_question(visitor_identifier, question_params) 12 def create_question(visitor_identifier, question_params)
13 - puts "the question_params are #{question_params.inspect}" 13 + logger.info "the question_params are #{question_params.inspect}"
14 visitor = visitors.find_or_create_by_identifier(visitor_identifier) 14 visitor = visitors.find_or_create_by_identifier(visitor_identifier)
15 question = visitor.questions.create(question_params.merge(:site => self)) 15 question = visitor.questions.create(question_params.merge(:site => self))
16 end 16 end