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 name
option of the submit_tag
method:
<%= submit_tag "Edit", :name => "edit[#{skt.id}]" %>
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_field
to track the id of the skt
you're editing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With