I have a survey taking page with a set of questions. Each question has five radio buttons. After answering the questions user clicks submit. Then based on the selection the values must be updated in the table called results.
Each row in the results table represents a unique radio button.
the code is here All the radio buttons each having unique result id are being passes in results.ids But I want only the selected ones. I am new to ruby on rails..can you please help me out?
<% if @questions.size>0 %>
<% form_tag :action => 'results_update', :method => :put do %>
<% for @q in @questions %> <%= "Q.#{@q.text}"%> <br /> <% @results = Results.where(:Questions_id => @q.id) %> <% for r in @results %> <%= radio_button_tag @q.id, 'results.ids',r.id%> <%=h r.id%> <br /> <% end %> <br /> <%end%> <p><%= submit_tag "Submit" %></p> </table> <% end %> <% else%>
<%= "There are no Questions in this survey"%> <%end%>