Starting a new project, I just try to rename my application.js to application.js.coffee.
Rails raise a error : SyntaxError: unexpected IDENTIFIER (in my_path/application.js.coffee)
Application.js is empty, just jquery include :
//= require jquery
//= require jquery_ujs
Any ideas? Thanks
Why would you want to do that?
It is not recommended to add code to your application.js.
If you need to run a coffee script just create a coffee file in the same folder and it will include it automatically.
From the comments in the file:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
This file is not your regular .js file, it serves the purpose of serving your javascripts to the asset pipeline, its not a good practice to add code here.
Whatever you need to do it can be done another way...
Comments in coffeescript are written with #
so replace with:
#= require jquery
#= require jquery_ujs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With