5

Does my ruby on rails app have to use coffeeScript or could I can I Just use plain javaScript?

1
  • 6
    remove .coffee from the end of your file and it runs plain js. so application.js.coffee -> application.js Commented Dec 19, 2013 at 16:03

4 Answers 4

7

You need to ensure not having the same filename both in javascript and coffeescript.

For example: having both the files

assets/javascripts/application.coffee  
assets/javascripts/application.js  

will only get the coffeescript loaded.

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

Comments

5

Yes, you can just use Javascript. You have your files in app/assets/javascripts/*.js . On local dev, do a view source and you will see your files there.

On production, the Asset Pipeline will concatenate and minify.

Comments

1

You can also write plain JS in CoffeeScript files, just put ` around it:

hi = `function() {
  return [document.title, "Hello JavaScript"].join(": ");
}`

1 Comment

In other words, you can have BOTH JS and CoffeeScript in the same .coffee file, if you enclose your JS code in backticks. Thanks, Qasim.
0

you can write whatever you want jquery or javascript just make sure the extension for that is js

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.