title: How to store course other than dropdown menu and open new textbox put other educations?
body: <p>Model field - degree, institute, percentage these are the model field.</p>
  
  <p>If course is other than dropdown menu so select "Other" and display textbox for enter user education. and when form submit i want to store education in degree column. but now i am not able to handle these two value. </p>
  
  <p>education.html.erb file</p>
  
  <pre><code>  &lt;p&gt;
      &lt;%= f.label :user_id, "Select User.*" %&gt;
      &lt;% if params[:user_id] != nil %&gt;
        &lt;%= f.select :user_id, :collection =&gt; User.where(:id =&gt; params[:user_id]).map{|u| ["#{u.firstname}, #{u.lastname}", u.id]} %&gt;
      &lt;% else  %&gt;
        &lt;%  @selected_user_id = EducationInformations.where(:id =&gt; params[:id]).pluck(:user_id).first  %&gt;
        &lt;%= f.select :user_id, :collection =&gt; User.where(:id =&gt; @selected_user_id).map{|u| ["#{u.firstname}, #{u.lastname}", u.id]} %&gt;
      &lt;% end  %&gt;  
    &lt;/p&gt;   
    &lt;br/&gt; 
    &lt;% course = ["MCA","BCA","BSC","Engg","Diploma in computer science","Other"] %&gt;
    &lt;p&gt;
      &lt;%= f.label :degree, "Select Course.*" %&gt;
      &lt;%= f.select :degree , :collection =&gt; (course) %&gt;
    &lt;/p&gt;
    &lt;div id="other_edu"&gt;
      &lt;br/&gt;
      &lt;p&gt;
        &lt;%= f.label :other_degree, "Enter your course" %&gt;
        &lt;%= f.text_field :other_degree , :id =&gt; "other_course", :onblur =&gt; "getCourse()" %&gt;
      &lt;/p&gt;
    &lt;/div&gt;
    &lt;br/&gt;
    &lt;p&gt;
      &lt;%= f.label :institute, "Institute*" %&gt;
      &lt;%= f.text_field :institute %&gt;
    &lt;/p&gt;
    &lt;br/&gt;
    &lt;p&gt;
      &lt;%= f.label :percentage, "Grade/Percentage" %&gt;
      &lt;%= f.text_field :percentage %&gt;
    &lt;/p&gt; 
  </code></pre>
  
  <hr>
  
  <pre><code>javascript
  
  $(document).ready(function() {
  
      var select = document.getElementById('education_informations_degree');
      var other_course = document.getElementById('other_course');
      $('#other_edu').hide(); 
  
          select.onchange = function() {
              var selected_course =  select.value;
              if (selected_course == "Other")
              {
                  $('#other_edu').show(); 
              }else{
                  $('#other_edu').hide(); 
              }
  
          }
  
      });
  
  function getCourse() {
          var x = document.getElementById("other_course"); 
          var select = document.getElementById('education_informations_degree');
          select.value = x.value;
          console.log(x.value);
      }
  </code></pre>
  
  <hr>
  
  <pre><code> Model
                                                                                              class EducationInformations &lt; ActiveRecord::Base
        unloadable
         attr_accessible :user_id, :degree, :institute, :passing_year, :country, :university, :percentage
  
          validates :degree, presence: true
          validates :passing_year, presence: true
          validates :university, presence: true
          validates :institute, presence: true
  
      end
  </code></pre>
  
  <hr>
  
  <pre><code>Controller 
  
      def create
          @edu_info = EducationInformations.new(educational_params)
  
              if @edu_info.save
                  #flash[:notice] = 'Vote saved.'
                  redirect_to @edu_info
              else
                  render "new"
              end     
  
      end
  
  private
  
      def educational_params
          params.require(:education_informations).permit(:user_id, :degree, :institute, :passing_year, :country, :university, :percentage)
      end
  </code></pre>