Nested form not complaining, but not saving data
<p>the forms for creating my polls show up correctly and the poll itself is created, but the answer options are not saved...</p>

<p>I am using rails 5.0.0.1</p>

<p>this is my db :</p>

<pre><code>class CreatePolls &lt; ActiveRecord::Migration[5.0]
  def change
    create_table :polls do |t|
      t.string :question

      t.timestamps
    end
  end
end
</code></pre>

<p>-</p>

<pre><code>class CreateAnswerOptions &lt; ActiveRecord::Migration[5.0]
  def change
    create_table :answer_options do |t|
      t.references :poll, foreign_key: true
      t.string :text
      t.integer :nbvotes, :default =&gt; 0

      t.timestamps
    end
  end
end
</code></pre>

<p>-</p>

<p>my models : </p>

<pre><code>class AnswerOption &lt; ApplicationRecord
  belongs_to :poll
end
</code></pre>

<p>-</p>

<pre><code>class Poll &lt; ApplicationRecord
  has_many :answer_options, :dependent =&gt; :destroy
  accepts_nested_attributes_for :answer_options
end
</code></pre>

<p>my controller : </p>

<pre><code>  # GET /polls/new
  def new
    @poll = Poll.new
    2.times { @poll.answer_options.build }
  end

  # POST /polls
  # POST /polls.json
  def create
    @poll = Poll.new(poll_params)

    respond_to do |format|
      if @poll.save
        format.html { redirect_to @poll, notice: 'Poll was successfully created.' }
        format.json { render :show, status: :created, location: @poll }
      else
        format.html { render :new }
        format.json { render json: @poll.errors, status: :unprocessable_entity }
      end
    end
  end
</code></pre>

<p>and my view : </p>

<pre><code>&lt;%= form_for(poll) do |f| %&gt;
  &lt;% if poll.errors.any? %&gt;
    &lt;div class="row"&gt;
      &lt;div id="error_explanation"&gt;
        &lt;h2&gt;&lt;%= pluralize(poll.errors.count, "error") %&gt; prohibited this poll from being saved:&lt;/h2&gt;

        &lt;ul&gt;
        &lt;% poll.errors.full_messages.each do |message| %&gt;
          &lt;li&gt;&lt;%= message %&gt;&lt;/li&gt;
        &lt;% end %&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  &lt;div class="row"&gt;
    &lt;div class="field form-group"&gt;
      &lt;%= f.label :question %&gt;
      &lt;%= f.text_field :question, :class =&gt; 'form-control' %&gt;
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;div class="row"&gt;
    &lt;div class="col-md-1"&gt;
      &lt;!--tab--&gt;
    &lt;/div&gt;
    &lt;div class="col-md-11"&gt;
      &lt;label for="options"&gt;Options&lt;/label&gt;
      &lt;ul class="list-group"&gt;
        &lt;%= f.fields_for :answer_options do |builder|%&gt;
          &lt;li class="list-group-item"&gt;
            &lt;%= builder.text_field :text %&gt;
          &lt;/li&gt;
        &lt;% end %&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;div class="row"&gt;
    &lt;div class="actions"&gt;
      &lt;%= f.submit "Create Poll", :class =&gt; 'btn btn-primary' %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;% end %&gt;
</code></pre>

<p>I can't find why the data is not being saved... I can create them in the rails console ans they get displayed in the show action. I tried playing with adding and removing 's' in the naming of poll or answer_option without success... </p>