title: Rails/Javascript: How to inject rails variables into (very) simple javascript
body: <p>I want to write up a very simple javascript calculator in rails which multiplies the quantity of an input field by a number stored in a rails variable (@item.base_price)</p>
  
  <p>So, on the javascript/coffeescript side of things, it's crudely this:</p>
  
  <pre><code># app/assets/javascript/items.js.coffee
  $ -&gt; 
    $('#item_quantity').change -&gt;
      quantity_val = $(this).val()
      $('#total_amount').html(quantity_val * &lt;%= I_WANT_@ITEM.BASE_PRICE_HERE %&gt;)
  </code></pre>
  
  <p>I'm aware of how I can do this via an ajax call on each change() call, but I figure there has to be an elegant, hopefully unobtrusive rails way which doesn't hit the server each time.</p>
  
  <p>Any suggestions very appreciated</p>