I have the following table with edit button in each. How can I detect which Edit button was clicked?
<table width="50%" border="1" height="50%" style='position:relative'><font color = "black">
<tr>
<th>SkillSet ID</th>
<th>SkillSet Name</th>
<th></th>
</tr>
<% for skt in @skillset %>
<tr>
<td><%= skt.SkillSetID%></td>
<td><%= skt.SkillSetName%></td>
<td><%= submit_tag "Edit"-%></td>
</tr>
<% end %>
</font></table>
<br>
</td>
</div>
<%end%>
You can use the
nameoption of thesubmit_tagmethod:Then in your controller you can check the key inside
params["edit"], where you should find something like(skt.id) => ''Alternatively, you could add a
hidden_fieldto track the id of thesktyou’re editing.