title: basic active record query
body: <p>I have a rails app with a three models called author, books and authorships. a book has many authors through a joint model called authorship and author has many books through a joint model called authorships for example </p>
  
  <pre><code>class Author &lt; ActiveRecord::Base
    attr_accessible :name
    has_many :authorships
    has_many :books, :through =&gt; :authorships
  end
  
  class Book &lt; ActiveRecord::Base
    attr_accessible :name, :author_ids
    has_many :authorships
    has_many :authors, :through =&gt; :authorships
  end
  
  class Authorship &lt; ActiveRecord::Base
    attr_accessible :book_id, :author_id
    belongs_to :book
    belongs_to :author
  end
  </code></pre>
  
  <p>Now my question is, How can i find books that as the similar authors any selected one</p>
  
  <p>for instance, <code>&lt;% book = Book.first %&gt;</code>
  something like </p>
  
  <pre><code>&lt;% book.similar_authors.each do |book| %&gt;
    #......
  &lt;% end %&gt;
  </code></pre>
  
  <p>What kind of query will i use to define <code>similar_authors</code></p>