Implementing a Coffeescript Application in Rails

I have a CoffeeScript that I am trying to add to my current rails application. Once the script is in the assets / javascript folder, how can I make it displayable on the page? I went through a bunch of tutorials and am completely lost so far. Do I need to create a new controller?

+3


source to share


1 answer


Coffeescript is included as a default gem in Rails. Confirm your selection in the Gemfile.



Coffeescript is a language that compiles, so it won't appear on the page - when you create a file .coffee

, Rails will compile it to JavaScript on page load (or sooner, depending on how you compile the assets). The coffeescript page is included the same as the js page is included (open the page application.js

- it will have a comment explaining how to enable JS).

+2


source







All Articles