Permalink
Browse files

Render views polymorphically

* Takes advantage of to_partial_path to render question collection
* Removes Divergent Change smell from surveys/show.html.erb
* Applies Replace Conditional with Polymorphism refactoring
  • Loading branch information...
jferris committed Nov 29, 2012
1 parent 4f9bdfe commit 8243493e1bd76bc7ad667d8baadf7def91ccfcc4
@@ -0,0 +1,8 @@
<ol>
<% multiple_choice_question.options.each do |option| -%>
<li>
<%= submission_fields.radio_button :text, option.text, id: dom_id(option) %>
<%= content_tag :label, option.text, for: dom_id(option) %>
</li>
<% end -%>
</ol>
@@ -0,0 +1 @@
<%= submission_fields.text_field :text %>

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,8 @@
<ol>
<% scale_question.steps.each do |step| -%>
<li>
<%= submission_fields.radio_button :text, step %>
<%= submission_fields.label "text_#{step}", label: step %>
</li>
<% end -%>
</ol>
@@ -19,7 +19,12 @@
<%= simple_form_for [@survey, @completion] do |form| -%>
<ol>
<% @questions.each do |question| -%>
<%= render 'questions/question', question: question, form: form %>
<%= form.fields_for "answers_attributes[#{question.id}]", Answer.new do |submission_fields| -%>
<li>
<%= submission_fields.label :text, label: question.title %>
<%= render question, submission_fields: submission_fields %>
</li>
<% end -%>
<% end -%>
</ol>
<%= form.submit 'Submit Answers' %>

0 comments on commit 8243493

Please sign in to comment.