then the 'index.js.erb' is rendered when your browser makes an AJAX
request to the 'index' action (in the same way that 'index.html.erb'
is rendered when your browser makes an ordinary request to the index
action).
These are two completely separate requests. index.js.erb is *not*
being inserted into a script tag in index.html.erb.
If you want that kind of thing to happen, you'll need to write a
custom view helper (and probably choose a more appropriate path for
your automatically-included JavaScript files, so that they don't
conflict with the standard behaviour described above).