title: Rails undefined method for array
body: <p>In my controller I am trying to run a query to get all of the id's not referenced in another table like so:</p>
  
  <pre><code>@vlan_numbers = ActiveRecord::Base.connection.execute("SELECT pop_vlans.id, vlan_number FROM pop_vlans WHERE pop_vlans.id NOT IN (SELECT logical_interfaces.vlan_id FROM logical_interfaces) AND pop_id != " + @pop_id.to_s)
  </code></pre>
  
  <p>Then in my view I am trying to use <code>collection_select</code> to show these in a dropdown menu:</p>
  
  
  
  <p>but the error I get is <code>undefined method 'vlan_number' for [2, "2"]:Array</code> where those values are just the first row of results from the query.</p>
  
  <p>This is a diagram of the two tables involved:</p>
  
  <pre><code>logical_interfaces | pop_vlans
  -------------------|-----------
       vlan_id-------|-----&gt;id
         ....        |  vlan_number
  </code></pre>
  
  <p>and the relationships in the models are:</p>
  
  <p><strong>pop_vlan.rb</strong></p>
  
  <pre><code>belongs_to :logical_interface
  </code></pre>
  
  <p><strong>logical_interface.rb</strong></p>
  
  <pre><code># no relationship defined
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>This is how the form is generated:</p>
  
  <pre><code>&lt;%= form_tag :controller =&gt; "circuit", :action =&gt; "update" %&gt;
      # other inputs
      &lt;%= select_tag options_for_select(@vlan_numbers) %&gt;
      # other inputs
   &lt;/form&gt;
  </code></pre>