diff --git a/app/controllers/candidate_controller.rb b/app/controllers/candidate_controller.rb index 31e1ca8..cb10cfe 100644 --- a/app/controllers/candidate_controller.rb +++ b/app/controllers/candidate_controller.rb @@ -18,7 +18,7 @@ class CandidateController < ApplicationController redirect_to :summary and return if qid.nil? prep_question qid - @answer = Answer.new + @answer = @question.answer.nil? ? Answer.new : Answer.find(@question.answer_id) end def update_answer diff --git a/app/views/candidate/live_coder.html.erb b/app/views/candidate/live_coder.html.erb index 97d0afd..5145907 100644 --- a/app/views/candidate/live_coder.html.erb +++ b/app/views/candidate/live_coder.html.erb @@ -1,16 +1,18 @@ +<% answer = @answer.answer || {} %> +
- <%= text_area_tag 'answer[live_code][html]', (@answer['html'] unless @answer.nil?), { 'data-id' => 'code-html', class: 'code-answer code-html' } %> + <%= text_area_tag 'answer[live_code][html]', (answer['html']), { 'data-id' => 'code-html', class: 'code-answer code-html' } %>
- <%= text_area_tag 'answer[live_code][css]', (@answer['css'] unless @answer.nil?), { 'data-id' => 'code-css', class: 'code-answer code-css' } %> + <%= text_area_tag 'answer[live_code][css]', (answer['css']), { 'data-id' => 'code-css', class: 'code-answer code-css' } %>
- <%= text_area_tag 'answer[live_code][js]', (@answer['js'] unless @answer.nil?), { 'data-id' => 'code-js', class: 'code-answer code-js' } %> + <%= text_area_tag 'answer[live_code][js]', (answer['js']), { 'data-id' => 'code-js', class: 'code-answer code-js' } %>
diff --git a/app/views/candidate/question.html.erb b/app/views/candidate/question.html.erb index 34eafc1..d479d02 100644 --- a/app/views/candidate/question.html.erb +++ b/app/views/candidate/question.html.erb @@ -5,7 +5,7 @@ content_for :footer_title, "Skills Assessment" %> -<%= form_for(@answer, url: post_answer_path(@answer.id), html:{id: 'answer-form', data: {qid: @question.question_id}}) do |form| %> +<%= form_for(@answer, url: post_answer_path(@answer.id), html:{method: :post, id: 'answer-form', data: {qid: @question.question_id}}) do |form| %>

<%= @question.question %>