title: How to setup model associations in Rails
body: <p>I'm trying to create associations for three models in my Rails application. In the application a User can access courses which have videos. How would I model this?</p>
  
  <p>This is what I currently have:</p>
  
  <pre><code>class User &lt; ApplicationRecord
   has_many :courses
   has_many :videos, through: :courses
  end
  
  class Course &lt; ApplicationRecord
   belongs_to :user
   has_many :videos
  end
  
  class Video &lt; ApplicationRecord
   belongs_to :course
   belongs_to :user
  end
  </code></pre>
  
  <p>Is this the correct way to model these associations for what I want the application to be able to achieve?</p>