Ruby on Rails Friday, September 28, 2012

I have a person has many questions model,  I have accepts_nested_Attributes set up properly.  the question from the db show up, but the index is not incrementing:


<%= f.fields_for :person_questions do |pregunta| %>
          Questions: <br/>
          <% Question.all.each do |question| %>
            <%= render 'questions/question_type', :pregunta => pregunta, :question => question, :f => f %>
          <% end %>
        <% end %>
        <div class="control-group">
          <%= f.label :date_of_problema, :class => 'control-label' %>
          <div class="controls">
            <%= f.datepicker :date_of_problema, :class => 'date_select' %>
          </div>
        </div>


partial:

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

Is there a way to get the attribute names to be correct?

The questions come from the db.
chrome inspector:
<input id="person_person_questions_attributes_0_option_selected" name="person[person_questions_attributes][0][option_selected]" type="checkbox" value="1">
<input id="person_person_questions_attributes_0_option_selected" name="person[person_questions_attributes][0][option_selected]" size="30" type="text">

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/lYzGc04VpAwJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment