title: Updating table fields with button click
body: <p>I'm trying to update cell in my table with the data from a drop down box in that row each time the button is clicked in that row.  Each row has a drop down box and a button as you can see in this image:</p>
  
  <p><a href="http://i.imgur.com/eVJumuk.png" rel="nofollow">http://i.imgur.com/eVJumuk.png</a></p>
  
  <p>I'm trying to set it up so that when user selects a value from a drop down box and clicks the update button it will update value of Room column only for that row.  But I can't figure out how to get the button even working and wanted to see if anyone can help me with this.</p>
  
  <p>Here is my controller:</p>
  
  <pre><code>def index
  @students = Student.all
  @first_floor = %w(1101 1102 1103 1104 1105)
  @second_floor = %w(2101 2102 2103 2104)
  @third_floor = %w(3101 3102 3103 3104)
  
  @selected_room = params[:room]
  
  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @students }
  end
  end
  </code></pre>
  
  <p>Here is the part of the view for the table:</p>
  
  <pre><code>&lt;% @students.each do |student|%&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;%= student.id %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%= student.n_number %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%= student.f_name %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%= student.l_name %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%= student.date_submit %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%= student.floor_pref %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%= @selected_room %&gt;&lt;/td&gt;
  &lt;% form_tag do %&gt;
  &lt;% if student.floor_pref == '1st' %&gt;
      &lt;td&gt;&lt;%= select_tag 'room', options_for_select(@first_floor.map { |value| [value,value]}, @selected_room) %&gt;&lt;/td&gt;
  &lt;% end %&gt;
  &lt;% if student.floor_pref == '2nd' %&gt;
      &lt;td&gt;&lt;%= select_tag 'room', options_for_select(@second_floor.map { |value| [value,value]}, @selected_room) %&gt;&lt;/td&gt;
  &lt;% end %&gt;
  &lt;% if student.floor_pref == '3rd' %&gt;
      &lt;td&gt;&lt;%= select_tag 'room', options_for_select(@third_floor.map { |value| [value,value]}, @selected_room) %&gt;&lt;/td&gt;
  &lt;% end %&gt;
  &lt;td&gt;&lt;%= submit_tag 'Update' %&gt;&lt;/td&gt;
  &lt;% end %&gt;
  &lt;td&gt;&lt;%= button_to 'Show', :controller =&gt; 'students', :action =&gt; 'preview', :id =&gt; student%&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%= button_to 'Remove', student, method: :delete, data: { confirm: 'Are you sure?' } %&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;% end %&gt;
  </code></pre>