title: Create a has_many through record
body: <p>I have a user a movie and a watchlist model in my Ruby project.</p>
  
  <p>movie.rb:</p>
  
  <pre><code>class Movie &lt; ApplicationRecord
    has_many :watchlists
    has_many :users, through: :watchlists
  end
  </code></pre>
  
  <p>user.rb</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_many :watchlists
    has_many :movies, through: :watchlists
    # Include default devise modules.
    devise :database_authenticatable,
           :registerable,
           :recoverable,
           :rememberable,
           :trackable,
           :validatable,
           # :confirmable,
           :omniauthable
    include DeviseTokenAuth::Concerns::User
  end
  </code></pre>
  
  <p>watchlist.rb</p>
  
  <pre><code>class Watchlist &lt; ApplicationRecord
    belongs_to :movie
    belongs_to :user
  end
  </code></pre>
  
  <p>And this is the MoviesController:</p>
  
  <pre><code>class MoviesController &lt; ApplicationController
  
    before_action :set_movie, only: [:show, :update, :destroy]
  
    # POST /movies
    def create
      if Movie.exists?(title: movie_params[:title])
        render json: { body: 'Movie already exists', status: 400 }
      else
  
        @movie = Movie.create!(movie_params)
        render json: { body: @movie, status: 200 }
      end
  
    end
  
    def movie_params
      # whitelist params
      params.permit(:title, :created_by, :id)
    end
  
  end
  </code></pre>
  
  <p>Currently I only store the movie in the movie table. How do I create a record in the watchlist that has a movie id and a user id?</p>