title: activerecord - query through attributes of related record
body: <pre><code>class Book
    belongs_to :library
  end
  
  class Library
    belongs_to :city
    has_many :books
  end
  
  class City
    has_many :libraries
    has_many :books, through: :library
  end
  </code></pre>
  
  <p>I want to be able to query</p>
  
  <pre><code>Book.where("library.city.name = ?", "Alexandria")
  </code></pre>
  
  <p>How do I correctly do this with ActiveRecord?</p>