title: Creating form for STI Model
body: <p>Referring to this post: <a href="https://stackoverflow.com/questions/10196181/rails-deal-with-several-similar-model-classes">Rails: Deal with several similar model classes?</a></p>
  
  <p><strong>Using combination of STI and Store feature to organize very similar models.</strong> </p>
  
  <p>"Declare a base model for Student with a text column called settings.</p>
  
  <pre><code>class Student &lt; ActiveRecord::Base
    store :settings
    # name, email, phone, address etc..
  end
  
  class HighSchoolStudent &lt; Student
    # declare HighSchoolStudent specific attributes 
    store_accessor :settings, :gpa
  end
  </code></pre>
  
  <p>How can I create a form for a HighSchoolStudent, while remaining under the Student controller?</p>
  
  <p>I dont want to add a separate controller or route resource for HighSchoolStudent, is there a way to have one form for Student and HighSchoolStudent, with a checkbox to indicate whether its a Student or a HighSchoolStudent? Can I only require that the extra attributes created for the subclass are only required for the form to be submitted if that specific class is checked?</p>
  
  <pre><code>&lt;%= simple_form_for(@student, html: {class: "form-horizontal"}) do |f| %&gt;
  </code></pre>
  
    
  
    
  
  <pre><code>&lt;%= f.input :name, as: :text, input_html: {rows: "1"} %&gt;
  &lt;%= f.input :email, as: :text, input_html: {rows: "2"} %&gt;
  
  &lt;%= f.input :gpa, as: :text, input_html: {rows: "1"} %&gt;
  
  
  &lt;%= f.button :submit, class: "btn btn-primary" %&gt;
  </code></pre>