title: how to select fields from joined table properly?
body: <p>here is my simplified models, i have joined models,</p>
  
  <p>model apartment</p>
  
  <pre><code>   has_many :towers
  </code></pre>
  
  <p>and</p>
  
  <p>model tower</p>
  
  <pre><code>   belong_to :apartment
  </code></pre>
  
  <p>and then i tried to join both tables in controller also tried it in rails console like this :</p>
  
  <blockquote>
    <p>Apartment.joins(:towers).select('apartments.id', 'apartments.name', 'towers.id' , 'towers.name')</p>
  </blockquote>
  
  <p>the problem is above query only returns</p>
  
  <blockquote>
    <p>apartments.id and apartments.name</p>
  </blockquote>
  
  <p>also tried to use alias like this, still no luck</p>
  
  <blockquote>
    <p>Apartment.joins(:towers).select('apartments.id', 'apartments.name',
    'towers.id as towerid' , 'towers.name as towername')</p>
  </blockquote>
  
  <p>i have confirmed that all towers have an apartment, i know i could do this to get 1 record</p>
  
  <blockquote>
    <p>Apartment.joins(:towers).select('apartments.id', 'apartments.name',
    'towers.id' , 'towers.name').first.towers.id</p>
  </blockquote>
  
  <p>and etc, but i need all records and all those fields, please advice.</p>
  
  <p>here is the latest result i got in rails console :</p>
  
  <pre><code> Apt Load (1.0ms)  SELECT apts.id, apts.apt_name, towers.id as towerid, towers.
      tower_name as towername FROM `apts` INNER JOIN `towers` ON `towers`.`apt_id` = `
      apts`.`id`
      =&gt; #&lt;ActiveRecord::Relation [#&lt;Apt id: 5, apt_name: "basura"&gt;, #&lt;Apt id: 5, apt_
      name: "basura"&gt;, #&lt;Apt id: 124, apt_name: "hydra"&gt;, #&lt;Apt id: 124, apt_name: "hy
      dra"&gt;, #&lt;Apt id: 126, apt_name: "mediterania"&gt;, #&lt;Apt id: 126, apt_name: "mediterania"&gt;, #&lt;Apt id: 142, apt_name: "apartement gajah mada"&gt;, #&lt;Apt id: 142, apt_name: "apartement gajah mada"&gt;]&gt;
  </code></pre>
  
  <p>as you can see, above query only return 2 fields, i need the result to be like this : </p>
  
  <pre><code>#&lt;Apt id: 126, apt_name: "mediterania", tower_id: 12, tower_name: "tower A"&gt;, 
  #&lt;Apt id: 126, apt_name: "mediterania", tower_id: 15, tower_name: "tower F"&gt;
  </code></pre>
  
  <p>etcc...</p>