title: Rails: How to associate a model with multiple parents
body: <p>I have a Note model in my app that I'd like to share with several other models. Something like:</p>
  
  <pre class="lang-sh prettyprint-override"><code>rails g model Note ...
  rails g model ModelA ... note:references
  rails g model ModelB ... note:references
  rails g model ModelC ... note:references
  </code></pre>
  
  <p>So far so good, but I think I'd like to have a way -- from a Note -- to find the "parent" model. Note that the models are different "things" so I don't think I can do this in the Note model:</p>
  
  <pre><code>belongs_to :model_symbol_here
  </code></pre>
  
  <p>Since the Note could belong to one of several different models.</p>
  
  <p>Conceptually it seems like I could do something like:</p>
  
  <pre class="lang-sh prettyprint-override"><code>rails g model Note parent_id:integer parent_type:string ...
  </code></pre>
  
  <p>I think that would work, but I think it would be at the expense of losing the ability to leverage Rails' understanding of the relationships between models.</p>
  
  <p>It seems like this is the sort of problem that would come up often enough that there would be a name for it as well as a "standard" solution. Is there a proper "Rails way" to do this?</p>