Hi, I am a newbie in Rails and need a lot of help for my upcoming
project for my scientific laboratory
for the basics on my application creation.
I have to create a form which includes Batches and Samples.
General idea would be Batches having (date received,
group_leader:string, contact_person:string, batch_comment and num_of
Samples:integer) . N.B batches have many samples.
now the Samples include ( Sample_name, Species, sample_type, ini_conc,
ini_vol, and sample_comment).
Now as these are of one to many relationships, I have created a form
after following many tutorials having a page showing batch detail
entry as well as asking for how many samples it involved in each
batch. After the user types in (for eg. 3), the form generates three
fields having sample details (also including name, species, type,
conc, vol, etc.) but I was not able to send these details to the
database. The only thing that updates the database is one sample
information.
my view looks something like this :
<h2>New sample</h2>
<% form_for(sample) do |f| %>
    <% (1..@batch.sample_no).each do |i| -%>
  <%= f.error_messages %>
  <p>
    <%= f.hidden_field :batch_id %>
  </p>
  <p>
    <%= f.label :sample_name %><br />
    <%= f.text_field :sname %>
  </p>
  <p>
    <%= f.label :organism %><br />
    <%= f.text_field :organism, :rows => 2 %>
  </p>
  <p>
    <%= f.label :sample_type %><br />
    <%= f.select(:samp_type, %w{ DNA RNA}) %>
  </p>
  <p>
    <%= f.label :ini_conc %><br />
    <%= f.text_field :ini_conc %>
  </p>
  <p>
    <%= f.label :ini_vol %><br />
    <%= f.text_field :ini_vol %>
  </p>
  <p>
    <%= f.label :storage_space %><br />
    <%= f.text_field :storage_space %>
  </p>
  <p>
    <%= f.label :samp_comment %><br />
    <%= f.text_area :samp_comment, :rows => 3 %>
  </p>
    <% end -%>
  <p><%= f.submit 'Submit' %></p>
<% end %>
## I haven't done anything much with my controller. (in fact I have no
idea which controller I should add codes to) meaning I have created
two scaffolds, one for batch and one for samples. and I have made a
partial of the samples_view_new.html.erb and saved it in the
batch_view folder which gives me an opportunity to add samples in the
show_html.erb of the batch.
Please could someone help me with this thing. its breaking my head a
lot.
Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to