title: How do you use a form select input for a polymorphic belongs_to association in Rails?
body: <p>I've got an Article model that has a polymorphic belongs_to association (resource).  I've been trying to let it set the association from the article form via two select boxes, one with the type and the other with id of the association as shown below.</p>
  
  <pre><code>= form_for @article do
    = f.select :resource_type, ...
    = f.grouped_collection_select :resource_id, ...
  </code></pre>
  
  <p>My problem is that it doesn't select the correct model in the grouped_collection_select if the association id exists in two of the associated models.</p>
  
  <p>There must be a better way to do this but I just can't seem to see it right now.</p>