Rails database not updating array in update action
<p>I am trying to update an array held in the database however the update action is not working. The array is not updated and no error is shown. Other parameters in the form are correctly updated in the database.</p>

<p>A form sends an array as one of the parameters (in this case <code>responses: []</code>):</p>

<pre><code>"task"=&gt; {"title"=&gt;"tasko uno", "responses"=&gt;["yes", "no", "maybe", "other"] ... }
</code></pre>

<p>The update action:</p>

<pre><code>def update
    @task = Task.find(params[:id])
    if @task.update(tasks_params)
      redirect_to edit_task_path
    else
      render 'new'
    end
  end
</code></pre>

<p>The params permissions:</p>

<pre><code>private
    def tasks_params
      params.require(:task).permit(:title, :help, :task_type, :taskflow_id, :responses =&gt; [])
    end
</code></pre>

<p>The database is the out the box sql-lite and the Task model has <code>serialize :responses, Array</code>, the array column is of type <code>text</code>, with a column title <code>responses</code>.</p>

<p>Any help would be much appreciated.</p>

<p>EDIT
The migration file:</p>

<pre><code>class CreateTasks &lt; ActiveRecord::Migration
  def change
    create_table :tasks do |t|
      t.string :title
      t.integer :task_type
      t.text :help
      t.text :responses
      t.belongs_to :taskflow
      t.timestamps null: false
    end
  end
end
</code></pre>

<p>Update action server log:</p>

<pre><code>Started PATCH "/tasks/1" for 127.0.0.1 at 2016-06-28 12:37:12 +0100
Processing by TasksController#update as HTML
  Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"BL2fI3JDIGfTqWxQHInR/NFI6N/agETaUb97lAZ86PpNmpj1ofQ+TRkHZNdiISyOMlag3geleig6PsaqaWNr8Q==", "task"=&gt;{"title"=&gt;"tasko uno", "help"=&gt;"some help text", "task_type"=&gt;"2", "taskflow_id"=&gt;"1"}, "responses"=&gt;["test1", "test2"], "commit"=&gt;"Update Task", "id"=&gt;"1"}
  Task Load (0.1ms)  SELECT  "tasks".* FROM "tasks" WHERE "tasks"."id" = ? LIMIT 1  [["id", 1]]
   (0.0ms)  begin transaction
   (0.0ms)  commit transaction
  Taskflow Load (0.1ms)  SELECT  "taskflows".* FROM "taskflows" WHERE "taskflows"."id" = ? LIMIT 1  [["id", 1]]
Redirected to http://localhost:3000/taskflows/1/edit
Completed 302 Found in 3ms (ActiveRecord: 0.2ms)
</code></pre>

<p>The form - I'm trying to have a form that adds fields dynamically:</p>

<pre><code>&lt;%= bootstrap_form_for @task do |f| %&gt;
  &lt;%= f.text_field :title %&gt;
  &lt;%= f.text_area :help %&gt;
  &lt;%= f.text_field :task_type %&gt;
  &lt;%= f.hidden_field :taskflow_id, value: @taskflow.id %&gt;
  &lt;hr&gt;
  &lt;p&gt;&lt;strong&gt;Responses&lt;/strong&gt;&lt;/p&gt;

  &lt;div class="admin-task-responses"&gt;
  &lt;% if @task.responses %&gt;
    &lt;% @task.responses.each do |r| %&gt;
      &lt;%= render "tasks/task_response", {:res =&gt; r} %&gt;
    &lt;% end %&gt;
  &lt;% end %&gt;
  &lt;/div&gt;

  &lt;div class="btn btn-primary add-response-btn"&gt;
    &lt;span class="glyphicon glyphicon-plus"&gt;&lt;/span&gt; Add Response
  &lt;/div&gt;

  &lt;%= f.submit %&gt;
&lt;% end %&gt;
</code></pre>

<p>The partial:</p>

<pre><code>&lt;% if local_assigns.has_key? :res %&gt;
&lt;div class="task-response form-group"&gt;
  &lt;%= text_field_tag "responses[]", '', :class =&gt; 'form-control', :value =&gt; res %&gt;
&lt;/div&gt;
&lt;% end %&gt;
</code></pre>