Re: Multiple rows of data with a single form
Hi,
After trying ankit644's code. I found this error message displaying regularly and I feel I have no values some where which makes it nil.
the errors shown are :
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Can any body tell me what mistake I am creating...
my view looks some think like this
<h2>New sample</h2>
<% form_tag :action => 'create' do %>
<% @samples.each_with_index do |sample, index| %>
<% fields_for "samples[#{index}]", sample do |f| %>
<table>
<tr>
<%= f.hidden_field :batch_id %>
<th><%= f.label :sample_name %><br />
<%= f.text_field :sname %></th>
<th><%= f.label :species %><br />
<%= f.text_field :organism, :rows => 2 %></th>
<th><%= f.label :sample_type %><br />
<%= f.select(:samp_type, %w{ DNA RNA}) %></th>
<th><%= f.label :initial_concentration %><br />
<%= f.text_field :ini_conc %></th>
<th><%= f.label :initial_volume %><br />
<%= f.text_field :ini_vol %></th>
<th>
<%= f.label :storage_space %><br />
<%= f.text_field :storage_space %></th>
<th>
<%= f.label :sample_comment %><br />
<%= f.text_area :samp_comment, :rows => 1 %></th>
</tr>
</table>
<% end %>
<% end %>
<p><%= f.submit 'Submit' %></p>
<% end %>
Last edited by a1aks (2011-06-21 10:15:26)