diff --git a/app/views/admin/question/_checkbox.html.erb b/app/views/admin/question/_checkbox.html.erb index 7c3db76..2bba6bb 100644 --- a/app/views/admin/question/_checkbox.html.erb +++ b/app/views/admin/question/_checkbox.html.erb @@ -3,7 +3,7 @@ @@ -12,7 +12,7 @@
Add option
  • - <%= text_field_tag 'question[input_options][]', nil, { disabled: (disable ||= false), data: { last: nil } } %> + <%= text_field_tag 'question[multi_choice][]', nil, { disabled: (disable ||= false), data: { last: nil } } %>
  • <% end %> diff --git a/app/views/admin/question/_form.html.erb b/app/views/admin/question/_form.html.erb index a3afa87..8574c00 100644 --- a/app/views/admin/question/_form.html.erb +++ b/app/views/admin/question/_form.html.erb @@ -1,14 +1,4 @@ -<% if flash[:error].present? %> -
    - <%= flash[:error] %> -

    - <% question.errors.messages.each do |k,v| %> - <%= "#{k.to_s} #{v.join(' and ')}" %>
    - <% end %> -

    -
    -<% end %> - +<%= render partial: 'shared/form_model_errors', locals: { obj: question} %> <%= form_for question, url: action do |form| %>
    <%= form.label :quiz_id, 'Quiz' %> diff --git a/app/views/admin/question/_live_code.html.erb b/app/views/admin/question/_live_code.html.erb index e2820f8..04af9e6 100644 --- a/app/views/admin/question/_live_code.html.erb +++ b/app/views/admin/question/_live_code.html.erb @@ -11,17 +11,17 @@
    - <%= text_area_tag 'question[input_options][html]', options['html'], { data: {id: 'code-html', last: options['html']}, class: 'code-answer code-html' } %> + <%= text_area_tag 'question[live_code][html]', options['html'], { data: {id: 'code-html', last: options['html']}, class: 'code-answer code-html' } %>
    - <%= text_area_tag 'question[input_options][css]', options['css'], { data: {id: 'code-css', last: options['css']}, class: 'code-answer code-css' } %> + <%= text_area_tag 'question[live_code][css]', options['css'], { data: {id: 'code-css', last: options['css']}, class: 'code-answer code-css' } %>
    - <%= text_area_tag 'question[input_options][js]', options['js'], { data: {id: 'code-js', last: options['js']}, class: 'code-answer code-js' } %> + <%= text_area_tag 'question[live_code][js]', options['js'], { data: {id: 'code-js', last: options['js']}, class: 'code-answer code-js' } %>
    diff --git a/app/views/admin/question/_radio.html.erb b/app/views/admin/question/_radio.html.erb index 6343cdc..b918fc7 100644 --- a/app/views/admin/question/_radio.html.erb +++ b/app/views/admin/question/_radio.html.erb @@ -3,7 +3,7 @@ @@ -12,7 +12,7 @@
    Add option
  • - <%= text_field_tag 'question[input_options][]', nil, { disabled: (disable ||= false), data: { last: nil } } %> + <%= text_field_tag 'question[multi_choice][]', nil, { disabled: (disable ||= false), data: { last: nil } } %>
  • <% end %> diff --git a/app/views/admin/quiz/_form.html.erb b/app/views/admin/quiz/_form.html.erb index 591a6f5..5815161 100644 --- a/app/views/admin/quiz/_form.html.erb +++ b/app/views/admin/quiz/_form.html.erb @@ -1,14 +1,4 @@ -<% if flash[:error].present? %> -
    - <%= flash[:error] %> -

    - <% quiz.errors.messages.each do |k,v| %> - <%= "#{k.to_s} #{v.join(' and ')}" %>
    - <% end %> -

    -
    -<% end %> - +<%= render partial: 'shared/form_model_errors', locals: { obj: quiz} %> <%= form_for quiz, url: action do |form| %>
    <%= form.label :name, "Quiz Description" %> diff --git a/app/views/admin/user/_form.html.erb b/app/views/admin/user/_form.html.erb index 4edf982..7b254c0 100644 --- a/app/views/admin/user/_form.html.erb +++ b/app/views/admin/user/_form.html.erb @@ -1,14 +1,4 @@ -<% if flash[:error].present? %> -
    - <%= flash[:error] %> -

    - <% user.errors.messages.each do |k,v| %> - <%= "#{k.to_s} #{v.join(' and ')}" %>
    - <% end %> -

    -
    -<% end %> - +<%= render partial: 'shared/form_model_errors', locals: { obj: user} %> <%= form_for user, url: action do |form| %>
    <%= form.label :name, "Full Name" %> diff --git a/app/views/recruiter/form.html.erb b/app/views/recruiter/form.html.erb index 343cc53..1a71a96 100644 --- a/app/views/recruiter/form.html.erb +++ b/app/views/recruiter/form.html.erb @@ -1,17 +1,7 @@

    New Candidate

    - <% if flash[:error].present? %> -
    - <%= flash[:error] %> -

    - <% @candidate.errors.messages.each do |k,v| %> - <%= "#{k.to_s} #{v.join(' and ')}" %>
    - <% end %> -

    -
    - <% end %> - + <%= render partial: 'shared/form_model_errors', locals: { obj: @candidate } %> <%= form_for @candidate, url: create_candidate_path do |form| %>
    <%= form.label :name, "Candidate name" %> diff --git a/app/views/shared/_form_model_errors.html.erb b/app/views/shared/_form_model_errors.html.erb new file mode 100644 index 0000000..5ae5829 --- /dev/null +++ b/app/views/shared/_form_model_errors.html.erb @@ -0,0 +1,10 @@ +<% if flash[:error].present? %> +
    + <%= flash[:error] %> +

    + <% obj.errors.messages.each do |k,v| %> + <%= "#{k.to_s} #{v.join(' and ')}" %>
    + <% end %> +

    +
    +<% end %>