I am creating a web page that displays a table. It also has four columns at the end of each record that are text fields where the user can enter data. When the user hits the submit button at the bottom I want to save all the data in all the text fields and add it to my table. How can I save the data for all the text fields? Here is my code.
<h1>Testing Table</h1>
<form action="/table/" method="POST">
<table>
<thead>
<tr>
<% event_column.each do |header| %>
<th>
<%= header %>
</th>
<% end %>
</tr>
</thead>
<tbody>
<% events.each do |event| %>
<tr>
<% event = event.first(14) %>
<% event.each do |key, value| %>
<td>
<%= value %>
</td>
<% end %>
<td><input type="text" name="event_description"></td>
<td><input type="text" name="event_type">
<td><input type="text" name="event_class">
<td><input type="text" name="issue_expert"></td>
</tr>
<% end %>
</tbody>
</table>
<br/>
<input type="submit">
<% ActiveRecord::Base.clear_active_connections! %>
</form>
I understand my issue. Since I am using the same variable to write all of the user entered columns when I try displaying in my POST method
<td><%= params[:event_description] %></td>
It will only display the last value entered because it's being reused. Is there anyway that when I hit submit I can loop through all the html text fields and save all the data? I'm pretty stuck here and I've searched all around. I understand how to save the text entry for the last row but, I don't know how to save all the text entries. I'm new to sinatra so I must be doing something fundamentally wrong.