> 
> **Possible Duplicate:**  
> 
> [Using Ruby variable in Javascript (In App View)](https://stackoverflow.com/questions/13673227/using-ruby-variable-in-javascript-in-app-view) 
> 
> 
> 

is there a way to create a kind of variable in a Ruby on Rails view to use it later in a javascript tag?

I want to do something like that:

```
    <p>
    <%  test=Build.where("result = 1").count(:result) %> of the builds succeeded.
    </p>

<%= javascript_tag do %>

            console.log(test);

<% end %>

```

Is there a way to do that? This is not working.
Thanks in advance!