Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExecJS problem compiling Rails 3.1 assets

My Rails 3.1.rc4 app was working fine, but I'm trying to figure out the appropriate way to store my js files in the pipeline. If I put any code in a file other than application.js, I get the following error:

Started GET "/assets/application.js" for 127.0.0.1 at 2011-07-21 23:15:02 -0500 Compiled ~/Dropbox/Rails/myapp/app/assets/javascripts/application.js.coffee (224ms) (pid 69397) Error compiling asset application.js: ExecJS::ProgramError: SyntaxError: Reserved word "function" on line 1 (in /Users/micahalcorn/Dropbox/Rails/myapp/app/assets/javascripts/users/registrations.js.coffee) Served asset /application.js - 500 Internal Server Error

This happens regardless of which file (registrations in this case) and claims a 'reserved word' regardless of the first word in the file (var, function, etc). I am using node.js as my runtime environment, and everything works fine if I remove coffeescript compiling gems and treat it like a Rails 3.0 app. I want to better understand the asset pipeline and follow conventions. Thanks for any suggestions!

like image 704
Micah Alcorn Avatar asked Feb 23 '23 12:02

Micah Alcorn


1 Answers

The error

SyntaxError: Reserved word "function" on line 1

is a CoffeeScript compiler error. Either convert function to -> in registrations.js.coffee, or rename it to registrations.js so that the file will be read as raw JavaScript.

like image 110
Trevor Burnham Avatar answered Feb 26 '23 21:02

Trevor Burnham