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