title: How to Render the CONTENTS of a Precompiled JavaScript File
body: <p>This might not be a common question, but I do need this feature.</p>
  
  <p>In my controller, I want to render a JavaScript file, named <code>ApplicationLike.js</code> with the following:</p>
  
  <pre><code>// This is a manifest file that'll be compiled into including all the files listed below.
  // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
  // be included in the compiled file accessible from http://example.com/assets/application.js
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
  // the compiled file.
  //
  //= require rr/lib/jquery-1.7.2.min.js
  //= (other requires)
  </code></pre>
  
  <p>and then in my controller, there is an <code>inject</code> action, I want to render the CONTENTS of the precompiled <code>ApplicationLike.js</code>, because it will be used as the <code>src</code> attribute of the following:</p>
  
  <pre><code>&lt;script src="//localhost:3000/app/inject.js/"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>We cannot use <code>javascript_include_tag</code>, because it will include the javascript tag <code>&lt;script type="text/javascript"&gt;&lt;/script&gt;</code>, which will cause syntax error, because we just need the PURE JavaScript contents for the <code>src</code> attribute of the above ALREADY-EXISTING <code>&lt;script&gt;</code> tag.</p>
  
  <p>I'm not sure if you guys understand what I'm talking about.</p>
  
  <p>I googled for more than 5 or 8 hours, no luck.</p>
  
  <p>I'm using Rails 3.2 and Ruby 1.9.3</p>
  
  <p>NOTE: <code>redirect_to /assets/ApplicationLike.js</code> will work, but I need to render more lines of JavaScript code that contains dynamic Ruby variables (for example <code>current_user.id</code>).</p>
  
  <p>BUT: of course, we can use a view called <code>inject.js.erb</code> that contains both the contents of <code>ApplicationLike.js</code> and more lines of JavaScript code as I mentioned.  I just don't know how to render JUST the CONTENTS of the precompiled <code>ApplicationLike.js</code> JavaScript file.</p>