title: modeling associations in Rails for Course, Institute, Location
body: <h2><strong>I was working on an App which has the following requirement:</strong></h2>
  
  <p>An admin (active_admin) can create courses for institutes.</p>
  
  <p>The relations between the entities are as follows:</p>
  
  <blockquote>
    <p>Course belongs to Institute 
    ( each course can belong to only one Institute).</p>
  </blockquote>
  
  <hr>
  
  <blockquote>
    <p>An <code>Institute</code> can have many <code>Locations</code> where it offers various <code>Courses</code>.</p>
  </blockquote>
  
  <p>Each <code>Location</code> for an <code>Institute</code> can provide many <code>Courses</code> and Each <code>Course</code> can be taught in many <code>Locations</code></p>
  
  <p>Im an not able to create a relation between Entities in such a way, so that the creation of a new <code>Course</code> requires the creation of <code>Institutes</code> and its <code>Locations</code>. Without <code>Institutes</code> and <code>Location</code> present <code>Course</code> cannot be created.</p>
  
  <h2>The way I was trying to achieve this was</h2>
  
  <p><code>Course</code> can be taught in many <code>Locations</code> through <code>Institutes</code>.</p>
  
  <p>But wasn't able to relate the Entities, such that the creation of <code>Course</code> required the creation of <code>Institutes</code> and its Locations.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Cheers.</p>