title: How do I achieve polymorphic relationships that reference a user?
body: <p>First, I have a polymorphic association setup because comments can belong to any object(in my case post and articles).  </p>
  
  <p>I want to be able to say:  </p>
  
  <pre><code>u = user.first
  u.comments #This will list all comments from a user
  u.comments.where(:commentable_type =&gt; "Post")  
  </code></pre>
  
  <p>This above line doesn't work. it generates a sql:
      SELECT "comments".* FROM "comments" WHERE "comments"."commentable_id" = 1 AND "comments"."commentable_type" = 'User' AND "comments"."commentable_type" = 'Post'  </p>
  
  <p>obviously this would return an empty list because a comment can't belong to 2 types. I also want to be able to say:  </p>
  
  <pre><code>f = Food.first
  f.comments.first.user #give me the user that posted the first comment
  </code></pre>
  
  <p>Here's my basic model... any tips on changing this?</p>
  
  <pre><code>class Comment &lt; ActiveRecord::Base
    belongs_to :commentable, :polymorphic =&gt; true
  end
  
  class Post &lt; ActiveRecord::Base
    has_many :comments, :as =&gt; :commentable
  end
  
  class Article &lt; ActiveRecord::Base
    has_many :comments, :as =&gt; :commentable
  end
  
  class User &lt; ActiveRecord::Base
      has_many :comments, :as =&gt; :commentable
  end
  </code></pre>