title: Rails join from two table: how select attribute
body: <p>In Rails 3.2.1</p>
  
  <p>I have:</p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
    attr_accessible :name, :description
    has_many :subprojects
  end
  
  
  class SubProject &lt; ActiveRecord::Base
    attr_accessible :id_name, :description, :num_alloc, :project_id
    belongs_to :projects
  end
  </code></pre>
  
  <p>How can i return in a rails controller, an object that contain the "name" attribute (from the Project model) and the <code>id_name</code>, <code>description</code> and <code>num_alloc</code> (from the SubProject model).</p>
  
  <p>In the controller, if i make</p>
  
  <pre><code>@results=  SubProject.joins('LEFT OUTER JOIN.......)
  </code></pre>
  
  <p><code>@results</code> contains only the attribute of the SubProject class because <code>SubProject.joins(...)</code> returns an <code>SubProject</code> object right? </p>
  
  <p>So how can i return an object with attribute from the two model?</p>