Commit 46688500980db55585294b1e82caa8019462645e
1 parent
cab664ce
Exists in
master
and in
1 other branch
trying to figure out why the prompt keeps regenerating
Showing
2 changed files
with
4 additions
and
2 deletions
Show diff stats
app/controllers/choices_controller.rb
| ... | ... | @@ -50,7 +50,8 @@ class ChoicesController < InheritedResources::Base |
| 50 | 50 | @question = Question.find params[:question_id] |
| 51 | 51 | |
| 52 | 52 | respond_to do |format| |
| 53 | - if @choice = current_user.create_choice(params['params']['data'], @question, {:data => params['params']['data'], :local_identifier => params['params']['local_identifier']}) | |
| 53 | + if @choice = current_user.create_choice(params['params']['data'], @question, {:data => params['params']['data'], | |
| 54 | + :local_identifier => params['params']['local_identifier']}) | |
| 54 | 55 | saved_choice_id = Proc.new { |options| options[:builder].tag!('saved_choice_id', @choice.id) } |
| 55 | 56 | choice_status = Proc.new { |options| |
| 56 | 57 | the_status = @choice.active? ? 'active' : 'inactive' |
| ... | ... | @@ -58,7 +59,7 @@ class ChoicesController < InheritedResources::Base |
| 58 | 59 | logger.info "successfully saved the choice #{@choice.inspect}" |
| 59 | 60 | format.xml { render :xml => @choice.to_xml(:procs => [saved_choice_id, choice_status]), :status => :ok } |
| 60 | 61 | # format.xml { render :xml => @question.picked_prompt.to_xml(:methods => [:left_choice_text, :right_choice_text], :procs => [saved_choice_id, choice_status]), :status => :ok } |
| 61 | - format.json { render :json => @question.picked_prompt.to_json, :status => :ok } | |
| 62 | + format.json { render :json => @question.to_json(:procs => [saved_choice_id, choice_status]), :status => :ok } | |
| 62 | 63 | else |
| 63 | 64 | format.xml { render :xml => @choice.errors, :status => :unprocessable_entity } |
| 64 | 65 | format.json { render :json => @choice.errors, :status => :unprocessable_entity } | ... | ... |
app/models/question.rb
| ... | ... | @@ -31,6 +31,7 @@ class Question < ActiveRecord::Base |
| 31 | 31 | begin |
| 32 | 32 | choice_id_array = distinct_array_of_choice_ids(rank) |
| 33 | 33 | @p ||= prompts.find_or_create_by_left_choice_id_and_right_choice_id(choice_id_array[0], choice_id_array[1], :include => [{ :left_choice => :item }, { :right_choice => :item }]) |
| 34 | + puts "#{@p.inspect} is active? #{@p.active?}" | |
| 34 | 35 | end until @p.active? |
| 35 | 36 | return @p |
| 36 | 37 | end | ... | ... |