Samuel
Samuel

Reputation: 6136

Using plain javaScript instead of coffeeScript

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

Upvotes: 5

Views: 4439

Answers (4)

weshouman
weshouman

Reputation: 933

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.

Upvotes: 7

Qasim
Qasim

Reputation: 1580

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

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

Upvotes: 1

timpone
timpone

Reputation: 19969

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.

Upvotes: 5

Nitin Jain
Nitin Jain

Reputation: 3083

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

Upvotes: 0

Related Questions