2016-04-28 21 views
0

Ich versuche, mein Formular zum Erstellen einer neuen Partitur (eine Partitur ist nur eine ganze Zahl zwischen 1 und 10). Ich habe http://guides.rubyonrails.org/form_helpers.html für Hilfe durchgelesen, und ich möchte Radioknöpfe verwenden, um dies zu tun. Ich tue es nicht richtig, aber ich kann nicht herausfinden, wie man den neuen Score mit dem richtigen Wert verbindet. Siehe untenRails Form Helfer, Radio Buttons

<h2 style="text-align:center"> 
     On a scale from 1-10, how likely are you to recommend this site to a friend or colleague? 
     </h2> 
     <%= form_for @score do |s| %> 
      <%= radio_button_tag(:value, 1) %> 
      <%= label_tag(:value, "1") %> 
      <%= radio_button_tag(:value, 2) %> 
      <%= label_tag(:value, "2") %>    
      <%= s.submit "Submit" %> 
     <% end %> 

Wert ist der Name des Feldes in meinen Partituren Tabelle

Antwort

0

Versuchen

<%= form_for @score do |s| %> 
    <%= s.radio_button :value, 1, id: "v_1" %> 
    <label for = "v_1">Label 1</label> 
    <%= s.radio_button :value, 2, id: "v_2" %> 
    <label for = "v_2">Label 2</label> 
    <%= s.submit "Submit" %> 
<% end %>