title: Create a variable in Ruby on Rails to use in Javascript
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/13673227/using-ruby-variable-in-javascript-in-app-view">Using Ruby variable in Javascript (In App View)</a>  </p>
  </blockquote>
  
  
  
  <p>is there a way to create a kind of variable in a Ruby on Rails view to use it later in a javascript tag?</p>
  
  <p>I want to do something like that:</p>
  
  <pre><code>    &lt;p&gt;
      &lt;%  test=Build.where("result = 1").count(:result) %&gt; of the builds succeeded.
      &lt;/p&gt;
  
  
  &lt;%= javascript_tag do %&gt;
  
              console.log(test);
  
  &lt;% end %&gt;
  </code></pre>
  
  <p>Is there a way to do that? This is not working.
  Thanks in advance!</p>