ruby - Unique radio buttons when iterating in rails -
i'm creating application in have list of symptoms (@all_symptoms) on iterating , want have radio buttons each 1 indicating whether presence true or false. the problem keep running against no matter try radio buttons named same, can select true/false once on entire form.
i tried changing label to:
<%= ff.radio_button "presence_#{s.id}", true %>
but there error because there (obviously) no method called "presence_x" symptoms. (for clarity: "presence" is attribute symptom, , accepts boolean value.)
the nested attribute part of form because part of appointment accepts attributes symptoms.
<%= f.fields_for :symptoms |ff| %> <table> <tr> <th>name</th> <th>presence</th> </tr> <% @all_symptoms.each |s| %> <tr> <td> <%= s.name %> </td> <td> <%= ff.label :presence, "true", :value => true %> <%= ff.radio_button :presence, true, :value => true %> <%= ff.label :presence, "false", :value => false %> <%= ff.radio_button :presence, false, :value => false %> </td> </table> <% end %>
have tried this?
<%= ff.radio_button :presence, true, :value => true, name: "presence_#{s.id}" %>
Comments
Post a Comment