Rails 3 : How can I put boolean data from check_box_tag in nested_form? -
actually tried radio_button, gave up.(too complicated me.)
i have db tables 'question', 'answer'.(those 2 tables has been related has_many , belongs_to, , nested_form relationship.)
and there user_answer(boolean, created default value 'false') column in answer table.
i want make this.
- if user check check_box, user_answer change 'true' value.
- then i'll compare value in correct column in answer table,
- and i'll save result in is_correct column in question table.
but don't know how can do. input form.
<h1><%= @survey.name %></h1> <%= form_tag({:controller => "surveys", :action => "grading"}) %> <ol class="questions"> <% @survey.questions.each |question| %> <li> <strong><%= question.content %></strong> <ol class="checkbox"> <% question.answers.each |answer| %> <%= check_box_tag(answer.user_answer) %> <%= label answer.content) %> <% end %> </ol> <hr /> </li> <% end %> </ol> <div><%= submit_tag("submit", :class => "submit") %></div> but answer.user_answer 'false', it's not changed @ all. how can change line?
<%= check_box_tag(answer.user_answer) %>
having:
<% question.answers.each |answer| %> <%= check_box_tag 'answers[]', answer %> <%= label answer.content %> <% end %> will send params[:answers] controller. of comparisons, etc. in controller.
Comments
Post a Comment