title: Rails - Polymorphism in single table inheritance
body: <p>I have three models, <code>Poem</code> and <code>Song</code> and <code>User</code>.
  Users can vote on any number of poems and songs. </p>
  
  <p>One solution would be to make two association models <code>PoemVote</code> and <code>SongVote</code></p>
  
  <pre><code>class PoemVote
    attr_accessible :poem_id, :user_id
    belongs_to :poem
    belongs_to :user
  end
  
  class SongVote
    attr_accessible :song_id, :user_id
    belongs_to :song
    belongs_to :user
  end
  </code></pre>
  
  <p>I can call <code>some_poem_vote.poem</code> and <code>some_song_vote.song</code></p>
  
  <p>However, <code>PoemVote</code> and <code>SongVote</code> are essentially the same. How do I use single table inheritance to extend the two from one parent <code>Vote</code> class?</p>
  
  <p>I'm thinking something along these lines:</p>
  
  <pre><code>class Vote
    attr_accessible :resource_id, :user_id
  end
  
  class PoemVote &lt; Vote
    ...not sure what goes here...
  end
  
  class SongVote &lt; Vote
    ...not sure what goes here...
  end
  </code></pre>
  
  <p>How do I make it work so that I can still call <code>some_poem_vote.poem</code> but underneath have PoemVotes and SongVotes share one database table? Or is there a better solution for my problem?</p>