title: how to do conditional include for polymorphic model when using to_json
body: <p>I have the following models:</p>
  
  <pre><code>class Feed &lt; ActiveRecord::Base
    belongs_to :post, :polymorphic =&gt; true
  end
  
  class Request &lt; ActiveRecord::Base
    has_one :feed, :as =&gt; :post, :dependent =&gt; :destroy
  end  
  
  class Recommendation &lt; ActiveRecord::Base
    belongs_to :item
    has_one :feed, :as =&gt; :post, :dependent =&gt; :destroy
  end  
  
  class Item &lt; ActiveRecord::Base
  end
  
  feed_obj.to_json(:include =&gt; {:post =&gt; :item})
  </code></pre>
  
  <p>The statement doesn't work b/c of the polymorphism. Requests don't have an associated item, but recommendations do. I need a way of conditionally including items.</p>