У меня проблемы с :reject_if
.Я не знаю, почему следующий код не работает.
Просмотр - _form.html.erb:
<%= f.fields_for :questions do |builder| %>
<div class="nested-field">
<%= builder.label :id, "Question" %><br />
<%= builder.collection_select(:id, Question.all(:order => 'question'), :id, :question, { :prompt => 'Select Question' } ) %>
</div>
<div class="nested-field">
<%= builder.label :test1 %><br />
<%= builder.text_field :test1 %>
</div>
<div class="nested-field">
<%= builder.label :test2 %><br />
<%= builder.text_field :test2 %>
</div>
<div class="nested-field">
<%= builder.label :description %><br />
<%= builder.text_field :description %>
</div>
<br /><br /><br />
<hr />
<% end %>
Модель - опроснаярб:
has_many :questions, :dependent => :destroy
accepts_nested_attributes_for :questions, :reject_if => lambda { |a| a[:id].blank? }, :allow_destroy => true
Большое спасибо!