title: rails joins models confusion (join many tables)
body: <p>Here is my three models/tables </p>
  
  <pre><code>class Swimming::Classschedule &lt; ActiveRecord::Base
  
    belongs_to :swimming_classtimes ,:class_name=&gt;'Swimming::Classtime',:foreign_key =&gt; "classtime_id"  
    attr_accessible :id,:coach_id, :level_id, :note, :classtime_id
  end
  
  
  class Swimming::Classtime &lt; ActiveRecord::Base
    has_many :swimming_classschedules,:class_name=&gt;'Swimming::Classschedule'
    belongs_to :swimming_timeblocks ,:class_name=&gt;'Swimming::Timeblock',:foreign_key =&gt; "timeblock_id"    
    attr_accessible :date, :end, :start,:timeblock_id,:id
  end
  
  
  class Swimming::Timeblock &lt; ActiveRecord::Base
    has_many :swimming_classtimes,:class_name=&gt;'Swimming::Classtime'
    attr_accessible :name,:id
  end
  </code></pre>
  
  <p>I would like do an inner join </p>
  
  <pre><code> select * from swimming_classschedules as c inner join swimming_classtimes as t on c.classtime_id = t.id inner join swimming_timeblocks as b on c.timeblock_id = b.id where c.date &gt;= "2013-06-01" and c.date &lt;= "2013-07-01" and c.timeblock_id = 5
  </code></pre>
  
  <p>and I would like to return all fields from these three tables not only from one table(say swimming_classschedules). I have read this page <a href="http://guides.rubyonrails.org/association_basics.html" rel="nofollow">http://guides.rubyonrails.org/association_basics.html</a> but still not clear how to inner join with rails models</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>tried the first answer</p>
  
  <pre><code>Swimming::Classschedule.joins(:swimming_classtimes).joins(:swimming_timeblocks).select("swimming_classtimes.*,swimming_timeblocks.*,swimming_classschedules.*").where("swimming_classtimes.date &gt;= '2013-06-01' and swimming_classtimes.date &lt;= '2013-06-08' ")
  </code></pre>
  
  <p>got this error message</p>
  
  <pre><code>ActiveRecord::ConfigurationError: Association named 'swimming_timeblocks' was not found; perhaps you misspelled it?
  </code></pre>
  
  <p>Thanks for any help</p>