title: How to remove duplicate entries to get unique elements when using collection_select? Getting error - any idea why?
body: <p>I am trying to do something somewhat common - generate an array of unique items in a list on a  form when using <code>collection_select</code>.  A User <code>has many</code> payments, and a Payment <code>belongs_to</code> user.  I am using Devise and so know the <code>current_user</code>.</p>
  
  <p>I can <strong>successfully</strong> generate a list of emails <strong>with duplication</strong> in the view using the code:</p>
  
  <pre><code>&lt;%= form_for(@payment) do |f| %&gt;
  .
  .
  .
     &lt;%= f.collection_select :email, current_user.payment, :email, :email, {:include_blank =&gt; "Please select"} %&gt;
  </code></pre>
  
  <p>However, I have not been able to get the same list of emails eliminating duplicates.  This question has been asked a few times on Stackoverflow, but I have not had success implementing the other solutions.  I have tried (without luck):</p>
  
  <pre><code>&lt;%= f.collection_select :email, current_user.payment.collect(&amp;:email).uniq, :email, :email, {:include_blank =&gt; "Please select"} %&gt;
  &lt;%= f.collection_select :email, current_user.payment.pluck(:email).uniq, :email, :email, {:include_blank =&gt; "Please select"} %&gt;
  </code></pre>
  
  <p>I get the error message <strong>undefined method 'email' for "test@example.com":String</strong>.  Can anyone help me understand (1) why the code I am using is incorrect, and (2) what change to make in the code? </p>
  
  <p>Greatly appreciate any help you can provide!</p>