Forum: Ruby on Rails Editing collections

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
610fa62f81578ee40c4fc8d3094fa927?d=identicon&s=25 harishkswamy (Guest)
on 2005-12-03 18:45
(Received via mailing list)

I spent all of last night trying to figure out how to edit a list of
objects. According to the Rails book the view should look like this:

<% for @transaction_detail in @transaction_details %>
<div id='trnDetail'>
    <%= select 'transaction_detail[]', 'account_id',
Account.find_all.collect {|p| [ p.path_name, ] }, {:include_blank
true}, {:class => 'accountList'} %>
    <%= text_field 'transaction_detail[]', 'quantity', :class => 'qty'
    <%= text_field 'transaction_detail[]', 'unit_price', :class =>
'unitPrice' %>
    <%= text_field 'transaction_detail[]', 'unit_conversion_rate',
:class =>
'unitConvRate' %>
<% end %>

This generates the following repeated html block:

<div id='trnDetail'>
	<select class="accountList" id="transaction_detail_account_id"
name="transaction_detail[account_id]"><option value=""></option>
<option value="1">Account 1</option>

	<input class="qty" id="transaction_detail_quantity"
name="transaction_detail[quantity]" size="30" type="text" />

	<input class="qty" id="transaction_detail_quantity"
name="transaction_detail[quantity]" size="30" type="text" />
	<input class="unitPrice" id="transaction_detail_unit_price"
name="transaction_detail[unit_price]" size="30" type="text" />
	<input class="unitConvRate"
name="transaction_detail[unit_conversion_rate]" size="30" type="text"

I guess this is how it should be, but when I submit I only get the
back for the first record. I know I am missing something very basic, can
another set eyes help me?

This topic is locked and can not be replied to.