I have a person has many questions through person_questions.  I have an 
extra column in the join table for the answer.  The section below works for 
a new submit but when I edit I get 3 each with the first 2 of each selected 
tand the third not so I get 6 check boxes some selected some not.  Is there 
a way to get this  to work properly os just the questions in the db show up 
once each with the appropriate ones checked?
The questions are in the db.


Questions: <br/>
        <% Question.all.each do |question| %>
          <%= f.fields_for :person_questions do |pregunta| %>
            <%= render 'questions/question_type', :pregunta => pregunta, 
:question => question, :f => f %>
          <% end %>
        <% end %>

Partial:

<div class="control-group">
  <%= pregunta.label question.name, (question.label_text unless 
question.label_text.nil?), :class => 'control-label' %>
  <div class="controls">
    <% if question.data_type == 'select' %>
      <%= pregunta.send(question.data_type, :answer, 
question.to_select,:class => "#{question.data_type}")  %>
      <%= pregunta.hidden_field :question_id, :value => question.id , 
:class => "#{question.data_type}" %>
    <% else %>
      <%= pregunta.send(question.data_type, :answer, :class => 
"#{question.data_type}" ) %>
      <%= pregunta.hidden_field :question_id, :value => question.id , 
:class => "#{question.data_type}" %>
    <% end %>
  </div>
</div>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/oHY14fbSOX0J.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to