title: Rails - Find results from two join tables
body: <p>I have have 3 Tables of data and 2 Join Tables connecting everything.  I'm trying to figure out a way to query the results based on the condition that the join table data is the same.</p>
  
  <p>To explain, I have User, Interest, and Event Tables.  These tables are linked through an HABTM relationship (which is fine for my needs since I dont need to store any other fields) and joined through two join tables.  So i also have a UsersInterests table with (user_id, interest_id) and a EventsInterests table with (event_id, interest_id). </p>
  
  <p>The problem comes when trying to query all the Events where the users interests match the events interests.  </p>
  
  <p>I thought it would look something like this...</p>
  
  <pre><code> @events= Event.find(:all, :conditions =&gt; [@user.interests = @event.interests])
  </code></pre>
  
  <p>but I get the error
  "undefined method `interests' for nil:NilClass", Is there something wrong with my syntax or my logic?</p>