title: Rails: How do I check a polymorphic association?
body: <p>I have the follow model setup:</p>
  
  <pre><code>class Favorite &lt; ActiveRecord::Base
    belongs_to :favoritable, :polymorphic =&gt; true
    belongs_to :user
  end
  
  class Photo &lt; ActiveRecord::Base
    belongs_to :user
    has_many :favorites, :as =&gt; :favoritable
  end
  
  class User &lt; ActiveRecord::Base
    has_many :photos
  end
  </code></pre>
  
  <p>And that <code>Favorite</code> model has <code>favoritable_id</code> and favoritable_type` fields.</p>
  
  <p>What I ultimately want to do is check and see if a <code>User</code> has already marked a photo as a favorite.</p>
  
  <p>I'm able to create the database record without issue...it's the checking to see if that user already has favorited the photo (or other data type) that I'm having issues with.</p>
  
  <p>I could obviously do some sort of raw SQL query to get it, but seems like there's gotta be a more "standard" way of doing it.</p>
  
  <p>I'm running Rails 3.0.3.</p>