I had this exact same problem and solved it, here are the details:
When you include one or more javascript files in your Rails 3.1 environment using application.js and //= require ...
, Rails will wrap the contents of your file with a <script> ..filecontents.. </script>
. You can verify this by running your site in development mode and doing a View | Source.
The problem is, in development mode, if you are not actually using that script, it may appear to work fine. But, Essentially, what you have is <script><script> ..filecontents.. </script></script>
.
However, when you attempt to PRECOMPILE the assets, something in that compiling process (sorry - I do not know what exactly) gags on the "<" in the inner script token.
Double-check your included .js files and, if any of them are wrapped by <script> ... </script>
remove those surrounding tags.
You should see that, in Development, everything still looks fine if you View Page Source. And, when you precompile your assets, the error should go away.
I ran into this problem with Google's recommended google-analytics javascript snippet and removing the script wrapper from the included file solved the problem.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…