title: Store Join Model Data in Rails
body: <p>I'm new to Ruby on Rails, and I'm developing a backend API.</p>
  <p>Currently, I got 2 Active Record Models called <strong>Book</strong> and <strong>Genre</strong>.</p>
  <h2>Active Record Model</h2>
  <pre><code>class Book &lt; ActiveRecord::Base
      has_and_belongs_to_many :genres
  end
  
  class Genre &lt; ActiveRecord::Base
      hast_and_belongs_to_many :books
  end
  </code></pre>
  <h2>DB Schema Model</h2>
  <pre><code>create_table :books do |t|
    t.string &quot;title&quot;
  end
  
  create_table :genres do |t|
    t.string &quot;genre&quot;
  end
  
  create_join_table :books, :genres do |t|
    t.index [:book_id, :genre_id]
    t.index [:genre_id, :book_id]
  end
  </code></pre>
  <h2>REST POST Request</h2>
  <pre><code> # POST /book
      def create
          book= Book.new(books_params)
  
          if book.save
              render json: {status: 'SUCCESS', message:'Book Saved', data: book},status: :ok
          else
              render json: {status: 'ERROR', message: 'Booknot saved', data: book.errors}, status: :unprocessable_entity
          end 
  
      end
  
  private
      def books_params
          params.require(:book).permit(:title)
      end
  </code></pre>
  <h2>QUESTION</h2>
  <p>I'd like to make an HTTP Post request to create a new book with it's <strong>genres</strong>. I've already tested the book insertion (without genres, just passing the book name), it works perfectly. However I'd also like to add some genre categories.</p>