title: rails 3 javascript not executed despite a text/javascript content-type in response
body: <p>I am performing an non-ajax GET request on a page. In the corresponding controller/action, I am returning javascript. However, this javascript is not being executed. Rather, it is showing up as text on my browser.</p>
  
  <p><strong>The action being hit:</strong></p>
  
  <pre><code>def my_action
    render :template =&gt; 'shared/_alert.js.erb', :content_type =&gt; 'text/javascript'
  end
  </code></pre>
  
  <p><strong>The js.erb file:</strong></p>
  
  <pre><code>alert("hello");
  </code></pre>
  
  <p><strong>Charles HTTP Request:</strong></p>
  
  <pre><code>GET /my_action HTTP/1.1
  Host: 172.16.151.186:3000
  User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Cache-Control: max-age=0
  Accept-Language: en-us
  Accept-Encoding: gzip, deflate
  Cookie: _session_id=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlZGZhMjFkOWRlNDQ3ZThlYjRiMzljNzMyMjg0N2E2YmJJIhBfY3NyZl90b2tlbgY7AEZJIjFtZ05jUmsxZlRIQ1FCaVVLczVCeUF2STNtY1gzUzhucTk3alF4RjVsVklFPQY7AEZJIhRjdXJyZW50X3VzZXJfaWQGOwBGSSIpYjMwNzg5NzItNDQzNi0xMWUxLTk5YzUtNGY3NjNlNzJhZmIyBjsARg%3D%3D--e345e67c4b130d2f3e4bdb48bd3d5d4f892f8272
  Pragma: no-cache
  Connection: keep-alive
  </code></pre>
  
  <p><strong>Charles HTTP Response:</strong></p>
  
  <pre><code>HTTP/1.1 200 OK 
  Content-Type: text/javascript; charset=utf-8
  Etag: "9b9a7c156c510c98d7fd224227f7431f"
  Cache-Control: max-age=0, private, must-revalidate
  X-Ua-Compatible: IE=Edge
  X-Runtime: 0.246125
  Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
  Date: Sat, 21 Jan 2012 15:23:09 GMT
  Content-Length: 15
  Connection: Keep-Alive
  Set-Cookie: _session_id=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlZGZhMjFkOWRlNDQ3ZThlYjRiMzljNzMyMjg0N2E2YmJJIhBfY3NyZl90b2tlbgY7AEZJIjFtZ05jUmsxZlRIQ1FCaVVLczVCeUF2STNtY1gzUzhucTk3alF4RjVsVklFPQY7AEZJIhRjdXJyZW50X3VzZXJfaWQGOwBGSSIpYjMwNzg5NzItNDQzNi0xMWUxLTk5YzUtNGY3NjNlNzJhZmIyBjsARg%3D%3D--e345e67c4b130d2f3e4bdb48bd3d5d4f892f8272; path=/; HttpOnly
  
  alert("hello");
  </code></pre>
  
  <p>Could some help me troubleshoot this? </p>
  
  <p>Thanks.</p>