我試圖創建與繭自稱是形式,問題的has_many問題,正在產生無限循環:(繭nested_form使自己
型號
class Question < ActiveRecord::Base
has_many :questions,:foreign_key => "parent_id", :dependent =>:destroy
belongs_to :basic_component
attr_accessible :description, :questions_attributes, :questions
end
我的問題_form
<%= semantic_form_for [:admin, @question] do |f| %>
<%= f.inputs do %>
<%= f.input :description %>
<div class="questions">
<%= f.semantic_fields_for :questions do |question| %>
<%= render 'question_fields', :f => question %>
<% end %>
<div class="links">
<%= link_to_add_association("Nova Pergunta", f, :questions, class: 'button') %>
</div>
</div>
<% end %>
<%= f.actions %>
<% end %>
我_question_fields
<div class="nested-fields">
<%= f.inputs do %>
<%= f.input :description} %>
<div class="questions">
<%= f.semantic_fields_for :questions do |question| %>
<%= render 'question_fields', :f => question %>
<% end %>
<div class="links">
<%= link_to_add_association("Nova Pergunta", f, :questions, class: 'button') %>
</div>
</div>
<% end %>
</div>
無限循環:(如何解決?
Rendered admin/questions/_question_fields.html.erb (168.4ms)
Rendered admin/questions/_question_fields.html.erb (376.2ms)
Rendered admin/questions/_question_fields.html.erb (586.4ms)
Rendered admin/questions/_question_fields.html.erb (780.2ms)
非常感謝。 –