title: Ruby on Rails Populate second dropdown based on 1st dropdown's selection
body: <p>Currently, I have a dropdown (<code>&lt;options&gt;</code>) that is pulling back a list of states in a database, and I want a second dropdown to appear and provide a list of cities associated with that state once the first dropdown is selected.</p>
  
  <p>Here are some samples of the files that I have to hopefully provide some clarification:</p>
  
  <p>models/states.rb:</p>
  
  <pre><code>class States &lt; ActiveRecord::Base
      has_many :cities
  end
  </code></pre>
  
  <p>models/cities.rb:</p>
  
  <pre><code>class City &lt; ActiveRecord::Base
      belongs_to :state
      # States are referenced by table column state_id
  end
  </code></pre>
  
  <p>Inside of the view that I'm working with, I have this:</p>
  
  <pre><code>  &lt;div class="field"&gt;
      &lt;%= f.label :state_id %&gt;&lt;br&gt;
      &lt;%= select(:city, :state_id, State.all.collect {|c| [c.name, c.id]}, {prompt: "Select state"}) %&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>but of course this only populates the first dropdown. Is there any easy way to accomplish my goal using any Ruby on Rails helpers? Or do I have to use ajax and jquery?</p>