2

I'm liking coffee!

Is there any reason I can't change my application.js file to application.js.coffee?

Thanks!

UPDATE:

I just tried changing it and got this error (along with 58 other errors): reserved word "function" on line 11 (in /Users/burtondav/sites/requestsys/app/assets/javascripts/application.js.coffee)

3
  • 1
    actually you can, why do you think you can't? Commented Jan 12, 2013 at 20:50
  • 1
    I'm fairly new to Rails. The application.js file has always been without the .coffee --> I never knew why. Commented Jan 12, 2013 at 20:55
  • try changing js comments // to coffee comments # (hash) Commented Feb 11, 2016 at 18:59

1 Answer 1

2

You are trying to rename a manifest file . It is a vital part of the asset-pipeline . It has a special purpose : to manage javasript assets . If you take a look at the default structure of the application.js file , you'll notice it is rather unusual . I think the better way to write in coffeescript is to create files with pieces of code and put them in related javascripts assets folders . Try to create a new js.coffee file and place it in app/assets/javascripts directory . In most usual cases it will be ready to operate . If you are about to translate javasript -> coffeescript , I guess you are aware of js2coffee tool.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.