CoffeeScript function created in app/assets/javascript not found
coffeescript, javascript, ruby-on-rails, ruby-on-rails-3
Solution
To make it accessible from outside, all you need to do is add an '@' in front. This will attach the function to the window object.
@myFunction = (variable) ->
Problem
In my CoffeeScript file, `clients.js.coffee`, ``` myFunction = (variable) -> ``` I created a function in CoffeeScript in `app/assets/javascript`. But when I try to call that function, the console shows me an error saying function not found. I check the source of the page and it shows that the script is loaded: ``` <script src="/assets/clients.js?body=1" type="text/javascript"></script> ``` This is what was found inside the script source: ``` (function() { var myFunction; myFunction = function(variable) {} }).call(this); ``` Any idea what am I missing? What should I do to call the function?