As we know, Rails 3.1 uses CoffeeScript and jQuery.
The old way I process ajax request is to respond to the request with a template whose name is some_action.js.erb
Now that we have CoffeeScript, and I want my template to be able to use the coffeescript syntax. So what can I do?
Just change the suffix name of the template file?
some_file.js.coffee this works fine in the assets / javascript directory.
But I am processing the ajax request, and its template is under the views folder, just changing the template name from some_action.js.erb to some_action.js.coffee.erb or some_action.js.coffee , this will not work, the rails treat it like a regular file and will not compile it from coffeescript syntax to regular javascript.
I am very sorry for my Enlgish ability, hope this time my question will explain my purpose.
source share