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.

  1. if user check check_box, user_answer change 'true' value.
  2. then i'll compare value in correct column in answer table,
  3. 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

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -