title: Rails Active Record, how to have an additional field parameter in the result of a query?
body: <p>I actually have this model:</p>
  
  <pre><code>class Role &lt; ActiveRecord::Base
    acts_as_authorization_role
  
    def self.all_join_wisp
      self.connection.select_all("SELECT roles.*, wisps.name AS wisp_name FROM roles LEFT JOIN wisps ON wisps.id = roles.authorizable_id")
    end
  end
  </code></pre>
  
  <p>the method all_join_wisp does almost what I want, it adds the field wisp_name, except it return a hash and not an active record object.</p>
  
  <p>Is there a way to retrieve an active record object instead?</p>
  
  <p>The Role model does not have belongs_to and the wisp model does not have has_many :roles , I guess it was done for flexibility or something (I did not develop the application I'm working on).</p>
  
  <h2>Edit: Solution implemented</h2>
  
  <p>Solution implemented here: <a href="https://github.com/nemesisdesign/OpenWISP-Geographic-Monitoring/blob/287861d95fffde35d78b76ca1e529c21b0f3a54b/app/models/role.rb#L25" rel="nofollow">https://github.com/nemesisdesign/OpenWISP-Geographic-Monitoring/blob/287861d95fffde35d78b76ca1e529c21b0f3a54b/app/models/role.rb#L25</a>
  Thanks to @house9</p>