title: Rails polymorphic has_many :through
body: <p>I'm pulling some data from an external API and would like to cache the results locally. I have a <code>class SearchTerm</code>, which I would like to be associated with a few different ActiveRecord types through the table <code>searchable_items</code>. I'm pretty sure I have the tables set up correctly, but something in my associations must be wrong.</p>
  
  <pre><code>class Foo &lt; ActiveRecord::Base
    has_many :search_terms, :as =&gt; :searchable, :through =&gt; :searchable_items
  end
  
  class Bar &lt; ActiveRecord::Base
    has_many :search_terms, :as =&gt; :searchable, :through =&gt; :searchable_items
  end
  
  class SearchTerm &lt; ActiveRecord::Base
    has_many :searchables, :through =&gt; :searchable_items
  end
  
  class SearchableItem &lt; ActiveRecord::Base
    belongs_to :search_term
    belongs_to :searchable, :polymorphic =&gt; true
  end
  </code></pre>
  
  <p>I would expect to be able to do something like <code>SearchTerm.find_by_term('SearchTerm').searchables</code> (and it would return an array of Foo and Bar objects) however, I get the error 
  <code>Could not find the association :searchable_items in model SearchTerm</code></p>
  
  <p>Thanks in advance for any insight you can provide to me!</p>