I am displaying all values in table formated
View:
<div style="clear:both; padding-top:1px;"> </div>
<%if @signals[0]!=nil %>
<h1>Signal</h1>
<div class="floatleft width100">
<div class="floatleft width100 padtop_15">
<div>
<table cellspacing="1" cellpadding="1" width="300px" border="0" id="mytable">
<tr>
<th class="title" style="width:20%"><strong>ID</strong></th>
<th class="title" style="width:40%"><strong>Signal</strong></th>
<th class="title" style="width:20%"><strong>Geo Subnode</strong></th>
<th class="title" style="width:20%"><strong>Track Number</strong></th>
</tr>
<%@signals.each do |signal| %>
<tr>
<td ><div align="left"><%= signal.ID %></div></td>
<td ><div align="left"><%= signal.Name %></div></td>
<td ><div align="left"><%= signal.Subnode %></div></td>
<td ><div align="left"><%= text_field_tag "sigtrack#{@sigtrk}", "#{signal.Tracknumber}", :size =>"30px",:class=>"inputbox_big2" %></div></td>
</tr>
<% @sigtrk=@sigtrk+1 %>
<%end%>
</table>
</div>
</div>
</div>
<%end%>
Controller:
@signals–> I am loading the table values(id,signal,subnode,tracknumber) for displaying all details
Issue:
User should be able to change the value and need to save those value with database…. here the issue is how to read the table formated field values?
If you want users to be able to change fields in order to store them in the database you need forms. Part 2 of the guide shows how to create a form for a model, use this information and your loop to create a form for each signal you have.
A more advanced way of changing values is to use AJAX calls, you could made editable table fields. This page shows a demonstation of this method, it is a bit out-dated, but it shows the possibilities. A lot of AJAX/Rails related information canbe found on SO as well.