title: Rails select from database
body: <p>Can somebody explain this ? , it is from ruby guides</p>
  
  <pre><code>&lt;%= collection_select(:person, :city_id, City.all, :id, :name) %&gt;
  </code></pre>
  
  <p>I have an attachment model, I want to select its version with combobox when I create an object, and also I want a new version option. </p>
  
  <blockquote>
    <p>here what attachment has</p>
  </blockquote>
  
  <pre><code>def change
  create_table :attachments do |t|
    t.string :filename
    t.attachment :file
    t.string :version
    t.text :description
    t.timestamps null: false
  end
  </code></pre>
  
  <blockquote>
    <p>UPDATE:</p>
  </blockquote>
  
  <pre><code>&lt;%= f.collection_select( :version,  Attachment.where.not(version: nil), :version, :version) %&gt;
  </code></pre>
  
  <p>it is working like that, but I don't understand,</p>