title: How to find unrated models with acts_as_rateable
body: <p>I have a rails application using the <code>acts_as_rateable</code> plugin.</p>
  
  <p>I'm stuck on figuring out how to retrieve unrated models using this plugin - however this is more of a general rails/SQL question than specific to this plugin.</p>
  
  <p>Acts as rateable adds the following to the schema:</p>
  
  <pre><code>create_table "ratings", :force =&gt; true do |t|
      t.integer  "rating",                      :default =&gt; 0
      t.string   "rateable_type", :limit =&gt; 15, :default =&gt; "", :null =&gt; false
      t.integer  "rateable_id",                 :default =&gt; 0,  :null =&gt; false
      t.integer  "user_id",                     :default =&gt; 0,  :null =&gt; false
      t.datetime "created_at"
      t.datetime "updated_at"
    end
  
    add_index "ratings", ["user_id"], :name =&gt; "fk_ratings_user"
  </code></pre>
  
  <p>And my rated models also have a user id column.</p>
  
  <p>I'd like to be able to retrieve all instances of a particular model that haven't been rated at all, and also all instances that haven't been rated by someone other than the creator of the model, e.g. here is one model:</p>
  
  <pre><code>class Review &lt; ActiveRecord::Base
    acts_as_rateable
  
    belongs_to :user
    ...
  end
  </code></pre>
  
  <p>So I want something like the following pseudocode</p>
  
  <pre><code>Review.find(:all, :conditions=&gt;"not rated by anyone")
  Review.find(:all, :conditions=&gt;"not rated by anyone except review.user")
  </code></pre>
  
  <p>However I can't figure out the SQL to do this, nor the rails magic to generate that SQL :-)</p>
  
  <p>Update: this query seems to find all models that ARE rated by somebody other than the user that owns the model. So I think I just need to invert this somehow.</p>
  
  <pre><code> Review.find(:all, 
    :joins=&gt;'left join ratings on reviews.id=ratings.rateable_id &amp;&amp; ratings.rateable_type="Review"', 
    :conditions=&gt;'reviews.user_id &lt;&gt; ratings.user_id', 
    :group=&gt;'reviews.id')
  </code></pre>