title: How to modify form based on drop down list selection in Rails?
body: <p>I have a form that asks the user to evaluated a person based on the position they have within the company.  However, the user needs the option to evaluate the person at a different position they don't currently occupy also.  While I have a drop-down-list to allow them to select the other position, my form currently doesn't update the questions it gives to the user to evaluate based on the new position.  How would I incorporate that?</p>
  
  <p><strong>reports_controller.rb</strong></p>
  
  <pre><code>def new
  
    # Find or create a new report
    @report = Report.unscoped.where(employee_id: @employee.id, author_id: current_user.id).first_or_initialize do |record|
       # Build new record if it didn't already exist
    end
  
    # Add skills for evaluations based on the employee's position
    @skills.includes(:positions).where(positions: { id: @employee.position.id }).each do |skill|
      @report.evaluations &lt;&lt; Evaluation.new(skill_id: skill.id) unless @report.evaluations.any? { |e| e.skill == skill}
    end
  
  end
  </code></pre>
  
  <p><strong>_form.html.erb</strong></p>
  
  <pre><code>&lt;%= simple_form_for([@employee, @report] do |f| %&gt;
    &lt;%= f.error_notification %&gt;
  
    &lt;!-- Drop Down list where user determines which position they wish to evaluate the employee for... --&gt;
    &lt;%= f.association :position, label: "Position Evaluated", selected: @employee.position.id %&gt;
  
  
    &lt;!-- Skills for the user to evaluate the employee, should change depending on the value selected from the drop down box. --&gt;
    &lt;%= f.nested_fields_for :evaluations do |fn| %&gt;
      &lt;%= fn.input :skill_id, as: :hidden, input_html: {value: fn.object.skill.id} %&gt;
      &lt;%= fn.object.skill.name %&gt;
      &lt;%= fn.association :grade %&gt;
      &lt;%= fn.input :explanation, input_html: { rows: 3 } %&gt;
    &lt;% end %&gt;
  
    &lt;% f.button :submit, "Update Report", class: "btn btn-primary" %&gt;
  &lt;% end %&gt;
  </code></pre>