title: Rails validate uniqueness of attribute according to another table
body: <p>I have a model <code>User</code>, which <code>has_many</code> <code>Profile</code>. I also have <code>Report</code> model, which <code>belongs_to</code> <code>Profile</code>.</p>
  
  <p>How can I make sure that one user has only one report? Something like</p>
  
  <pre><code>class Report
    validate_uniqueness_of profile_id, scope: :user 
  end
  </code></pre>
  
  <p>would be great, but of course it doesn't work. (I don't want to attach user field to Report, because it mixes up ownership chain).</p>