Call javascript function onclick in Rails
问题 I have the following code in one of my views: <button type="button" onclick="analyze();">Analyze</button> And, the .js.coffee file for the corresponding controller contains analyze = -> $.ajax type: "GET" url: "http://localhost:3000/api/logs" success: (data) -> Analytics.doAnalysis data return; return; But, when I click the button, I get an error in console saying Uncaught ReferenceError: analyze is not defined . I think my onclick is not correctly defined. What is the recommended way of