Hi!
I''m a RoR newbie and i''m trying to make this sample code
work...
I must be able to choose whether or not to switch lights on/off (one
light per line)
<table>
<% @valeurs.each do |@v| %>
<tr>
<td>Light <%= Light.find(@v.light_id).nom %>:</td>
<td><%= radio_button(''v[]'',
''etat'', "Off") %> Off</td>
<td><%= radio_button(''v[]'',
''etat'', "On") %> On</td>
<td>Intensite :<%= text_field(''v[]'',
''intensite'') %></td>
</tr>
<% end %>
</table>
I understand the problem : because I use v[] as name in each
radio_button, I can select only one radio_button whatever the line.
But I don''t know how to address this. Kind of newbie problem I think,
some help appreciated ;-)
In my controller:
(If no value found, I generate some values with defaults code so that
the table displays correctly:)
___________________
@scenario = Scenario.find(params[:id])
@valeurs=Valeur.find_all_by_scenario_id(params[:id], :order => "light_id
ASC")
if (@valeurs == nil) | (@valeurs.length == 0)
lights=Light.find_all
lights.each do |l|
@valeur = Valeur.new do |v|
v.light_id = l.id
v.scenario_id = params[:id]
v.intensite = 0
v.etat = "Off"
end
@valeurs.push(@valeur)
end
end
_______________________
Thanks again...
--
Posted via http://www.ruby-forum.com/.