title: has_and_belongs_to_many with join table and checkbox collection
body: <p>I am trying to make an admin page that has a nested form for another model.</p>
  
  <p>I have a Playbook model:</p>
  
  <p><strong>playbook.rb</strong></p>
  
  <pre><code>  has_and_belongs_to_many :groups
    accepts_nested_attributes_for :groups
  </code></pre>
  
  <p>my form view</p>
  
  <p><strong>_form.html.haml</strong></p>
  
  <pre><code>&lt;%= form_with(model: playbook, local: true) do |form| %&gt;
  
     ...
  
    &lt;%= collection_check_boxes(:group, :group_ids, Group.all, :id, :name) %&gt;
  
    &lt;div class="actions"&gt;
      &lt;%= form.submit %&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>To explain it more, playbooks can have many groups which are another model and I want to save to the groups_playbooks join table automatically when saving the playbook using what I think would be a nested form. I just dont know how to do the nested form with a collection of checkboxes like my view.</p>
  
  <p>Here is part of schema to help give a better picture:</p>
  
  <pre><code>  create_table "groups", force: :cascade do |t|
      t.string "name"
      t.string "variables"
      t.bigint "server_id"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
      t.index ["server_id"], name: "index_groups_on_server_id"
    end
  
    create_table "groups_playbooks", id: false, force: :cascade do |t|
      t.bigint "group_id", null: false
      t.bigint "playbook_id", null: false
    end
  
    create_table "groups_servers", id: false, force: :cascade do |t|
      t.bigint "group_id", null: false
      t.bigint "server_id", null: false
    end
  
    create_table "playbooks", force: :cascade do |t|
      t.string "name"
      t.string "play"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
      t.string "description"
    end
  
    create_table "playbooks_servers", id: false, force: :cascade do |t|
      t.bigint "playbook_id", null: false
      t.bigint "server_id", null: false
    end
  
    create_table "servers", force: :cascade do |t|
      t.string "name"
      t.string "ip"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
      t.bigint "group_id"
      t.index ["group_id"], name: "index_servers_on_group_id"
    end
  </code></pre>