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)
Light <%= Light.find(@v.light_id).nom %>: |
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…