title: Error declaring a Javascript variable in Rails 3
body: <p>I get an error when declaring a variable in Javascript, and Rails 3.1.
  There are no problems whatsoever if I put the following code on my index.html.erb:</p>
  
  <pre><code>&lt;div id='show_time_id' style="background-color: #eee"&gt;
  
  &lt;script type="text/javascript"&gt;
  function updateClock ( )
  {
  var currentTime = new Date ( );
  
  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );
  
  .......
  
  
  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
  }
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(
      function(){
          setInterval('updateClock()', 1000 )
      });
  &lt;/script&gt;
  &lt;/div&gt;
  
  &lt;div style="width: 10em; text-align: right; margin: 20px auto;"&gt;
  &lt;span id="clock"&gt;&amp;nbsp;&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>However, if I put the code into a assets\javascript\clock.js file, and then put <code>&lt;%= javascript_include_tag 'clock' %&gt;</code>   in my index.html.erb file, I get this error in the error console:</p>
  
  <blockquote>
    <p>syntax error<br>
    <a href="http://localhost:3000/assets/clock.js?body=1" rel="nofollow">http://localhost:3000/assets/clock.js?body=1</a><br>
    var currentTime = new Date ( );  </p>
  </blockquote>
  
  <p>It's not a very important matter, since I can leave the code in index.html.erb, but still I'd like to know. Any idea why does this happen?</p>