title: pass javascript variable to ruby on rails controller to send in api further
body: <p>I am having a google api map as index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no"&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;style&gt;
    html, body {
      height: 100%;
      margin: 0;
      padding: 0;
    }
    #map {
      height: 100%;
    }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="map"&gt;&lt;/div&gt;
  &lt;script&gt;
    // Note: This example requires that you consent to location sharing when
    // prompted by your browser. If you see the error "The Geolocation service
    // failed.", it means you probably did not give permission for the browser to
    // locate you.
  
    function initMap() {
      var map = new google.maps.Map(document.getElementById('map'), {
        center: {lat: -34.397, lng: 150.644},
        zoom: 15
      });
      var infoWindow = new google.maps.InfoWindow({map: map});
  
      // Try HTML5 geolocation.
      if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
          var pos = {
            lat: position.coords.latitude,
            lng: position.coords.longitude
          };
  
          infoWindow.setPosition(pos);
          infoWindow.setContent('Location found.');
          map.setCenter(pos);
        }, function() {
          handleLocationError(true, infoWindow, map.getCenter());
        });
      } else {
        // Browser doesn't support Geolocation
        handleLocationError(false, infoWindow, map.getCenter());
      }
    }
  
    function handleLocationError(browserHasGeolocation, infoWindow, pos) {
      infoWindow.setPosition(pos);
      infoWindow.setContent(browserHasGeolocation ?
                            'Error: The Geolocation service failed.' :
                            'Error: Your browser doesn\'t support geolocation.');
    }
  
  
  
      &lt;/script&gt;
      &lt;script async defer
  src="https://maps.googleapis.com/maps/api   /js?key=AIzaSyBNvjq57_K8vPYRKETMN6bDogqCpRvBoA0&amp;callback=initMap"&gt;
      &lt;/script&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>I want to use the var=pos in ruby on rails controller i.e products controller</p>
  
  <pre><code>require 'rubygems'
  
      require 'httparty'
  
      class ProductsController &lt; ApplicationController
  
  
  
  def index
  
      @results = HTTParty.get("https://api.uber.com          /v1/products?server_token=xyz&amp;latitude=37.7759792&amp;longitude=-122.41823").parsed_response
  
     respond_to do |format|
     format.json { render :json =&gt; JSON.parse(@results) }
     format.html { render "index.html.erb" }
     end
     end
     end
  </code></pre>
  
  <p>and then pass seperate latitude and longitude in the api url so that it can take any latitude and longitude instead of giving it manually. 
  How can I do it ? Any suggestion would be appreciated.</p>