title: Passing JavaScript variable to ruby-on-rails controller
body: <p>How can I pass a variable (id) from the JavaScript listener:</p>
  
  <pre><code>Gmaps.map.callback = function() { 
      ...
      ...
      google.maps.event.addListener(marker, 'click', function() {
        var id = this.currentMarker;
        alert(id); 
      });
     }
    }
  </code></pre>
  
  <p>To the instance variable (@foo) in ruby-on-rails controller</p>
  
  <pre><code>def create
    @foo = ???
    ...
  end
  </code></pre>
  
  <p>to correctly create a relationship in the view (form):</p>
  
  <pre><code>&lt;%= form_for user.relationships.build(:followed_id =&gt; @foo.id) do |f|    %&gt;
  &lt;div&gt;&lt;%= f.hidden_field :followed_id %&gt;&lt;/div&gt;
  &lt;div class="actions"&gt;&lt;%= f.submit "Follow" %&gt;&lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Thanks!</p>