title: Pass ruby variables to js code
body: <p>Im curious what is the best way to pass my rails variables into javascript code. For example i have this line in my controller:</p>
  
  <pre><code>@address = get_user_address
  @farms = Farm.all
  </code></pre>
  
  <p>Now i need to use it for initialize my google map, for now im going with plain javascript and im more than sure that this is ugly solution. In view im have something like that</p>
  
  <pre><code>%script
    distance = []
    - @farms.each do |f|
      distance.push(['#{f.latitude}' + ',' + '#{f.longitude}' + ',' + '#{f.name}', #{f.distance_from(@address)}])
    distance.sort(sortMultiDimensional)
    user_coords = #{Geocoder.coordinates(@address)}
  </code></pre>
  
  <p>And google map initalize going under. How to avoid this ugly ruby-in-javascript code? Thanks! </p>