title: Rails 6 nested form cocoon won't save sub-objects
body: <p>I am trying to implement a nested form for a Book object which can have several BookAuthor objects. I have followed <a href="https://www.youtube.com/watch?v=R2iw5BAKBNA" rel="nofollow noreferrer">this</a> tutorial to do this with the Cocoon gem in Rails 6, however it does not work. The form itself works well on the front end, adding and removing the BookAuthor fields properly. The params that the server receives contain the correct number of BookAuthor attributes but these sub-objects do not get written to the database, even though the main Book object does. I have been able to get the association to work properly.</p>
  
  <p>There is no error output from either the javascript or rails consoles.</p>
  
  <p>Notes: Ignore the <code>include Hashid::Rails</code> in book.rb, I have tried both with and without this and the same thing occurs. Also, ignore any references to Chapter objects in book.rb, as these are not part of the form yet.</p>
  
  <p>Below is the code for the relevant models, views and controllers. The model files also contain the table schema for that model. If there is any more code you require, please let me know.</p>
  
  <p>Params the server receives (from the server console): <a href="https://pastebin.com/nxAXkD3T" rel="nofollow noreferrer">https://pastebin.com/nxAXkD3T</a></p>
  
  <p>book.rb: <a href="https://pastebin.com/Xtxf52eT" rel="nofollow noreferrer">https://pastebin.com/Xtxf52eT</a></p>
  
  <p>book_author.rb: <a href="https://pastebin.com/miFhb5wR" rel="nofollow noreferrer">https://pastebin.com/miFhb5wR</a></p>
  
  <p>_form.html.haml: <a href="https://pastebin.com/YaW1gRUe" rel="nofollow noreferrer">https://pastebin.com/YaW1gRUe</a></p>
  
  <p>_book_author_fields.haml: <a href="https://pastebin.com/FJw7CR2f" rel="nofollow noreferrer">https://pastebin.com/FJw7CR2f</a></p>
  
  <p>books_controller.rb: <a href="https://pastebin.com/0NYsCc7x" rel="nofollow noreferrer">https://pastebin.com/0NYsCc7x</a></p>
  
  <p>application.js: <a href="https://pastebin.com/rZLpe0iS" rel="nofollow noreferrer">https://pastebin.com/rZLpe0iS</a></p>
  
  <p>Gemfile: <a href="https://pastebin.com/TcGrQ9f5" rel="nofollow noreferrer">https://pastebin.com/TcGrQ9f5</a></p>
  
  <p>Gemfile.lock: <a href="https://pastebin.com/apCMxNkJ" rel="nofollow noreferrer">https://pastebin.com/apCMxNkJ</a></p>
  
  <p>package.json: <a href="https://pastebin.com/9U7mB2NK" rel="nofollow noreferrer">https://pastebin.com/9U7mB2NK</a></p>
  
  <p>yarn.lock: <a href="https://pastebin.com/H3AzG3Bi" rel="nofollow noreferrer">https://pastebin.com/H3AzG3Bi</a></p>