title: Rails Scope: Select Distinct Title With Values
body: <p>I'm having trouble with an SQL query in a scope. I need to return a collection of unique Project.titles and their accompanying ids for use in a form.</p>
  
  <p>I can get the distinct title using</p>
  
  <pre><code>scope :unique_title, select("DISTINCT title")
  </code></pre>
  
  <p>But I don't get the value in the resulting options</p>
  
  <p><code>= project_form.input :id, collection: current_user.projects.unique_title</code></p>
  
  <p>Result:</p>
  
  <pre><code>&lt;select&gt;
    &lt;option value&gt;Item 1&lt;/option&gt;
    &lt;option value&gt;Item 2&lt;/option&gt;
    &lt;option value&gt;Item 3&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>So, adding id to my scope:</p>
  
  <pre><code>scope :unique_title, select("DISTINCT title").select("id")
  </code></pre>
  
  <p>Result gives me the values but now my DISTINCT selection is defunct:</p>
  
  <pre><code>&lt;select&gt;
    &lt;option value="1"&gt;Item 1&lt;/option&gt;
    &lt;option value="2"&gt;Item 2&lt;/option&gt;
    &lt;option value="3"&gt;Item 3&lt;/option&gt;
    &lt;option value="4"&gt;Item 2&lt;/option&gt;
    &lt;option value="5"&gt;Item 2&lt;/option&gt;
    &lt;option value="6"&gt;Item 2&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>