title: How do i populate a select with a db call based on another select
body: <p>I have a form whereby dropdown 2 is populated as a result of the selection made in another select dropdown 1. If dropdown 1 one had options A, B &amp; C (separate call from the database) if I select A the application will do a GET with A as a variable and populate the dropdown 2 with the returned results. </p>
  
  <p>I was thinking this could be done in a number of ways but have not quite figured out which direction to take. The first approach I was going to take is to perform the calls straight away and add values associated with A, B and C to dropdown 1 so when it is activated the additional values populate dropdown 2. Additionally i was also trying to figure how to fire a HTTP GET call dynamically based on user hitting the first select.</p>
  
  <p>Can anyone give some pointers about how to achieve this. </p>
  
  <p>EDIT</p>
  
  <p>An example of how we perform HTTP gets</p>
  
  <pre><code>def get_call(routePath)
    started_at = Time.now
    enc_url = URI.encode("#{settings.abacus_service_endpoint}#{routePath}")
    uri = URI.parse(enc_url)
    http = Net::HTTP.new(uri.host, uri.port)
  
    req = Net::HTTP::Get.new(uri.request_uri, get_header_for_abacus_service)     
    resp = http.request(req)
    logger.bench 'SERVICE - GET', started_at, routePath
    return resp if response_ok?(resp)
  end
  </code></pre>