Reputation: 1635
I use rails 3.1.0rc4 and coffee-script 2.2.0. app/assets/javascripts/application.js includes:
//= require users
In app/assets/javascripts/users.js I have following code:
jQuery(document).ready(function($) {
alert('OK');
});
How to convert it to coffee-script? When I replace:
jQuery(document).ready
with
$->
and change the filename from users.js to users.js.coffee
it throws ExecJS::RuntimeError.
Upvotes: 0
Views: 1539
Reputation: 77416
The answer to your problem is simple: The input
$->
causes the CoffeeScript compiler to complain
Error: Parse error on line 1: Unexpected '->'
You need to either add a space:
$ -> alert 'OK'
or use explicit parentheses:
$(-> alert 'OK')
Upvotes: 3