title: Rails, JQuery: onClick event not attaching?
body: <p>I think I'm missing out on some fundamental aspect of how Javascript is handled by Rails.</p>
  
  <p>I created a new Rails project using Ruby 2.1.0.</p>
  
  <pre><code>$ mkdir whatishappening
  $ cd whatishappening
  $ rails new .
  $ rails generate scaffold post title body:text
  $ rails db:migrate
  $ rails server
  </code></pre>
  
  <p>I then proceeded to create a test post.  After that I added:</p>
  
  <p><em>whatishappening/app/views/posts/show.html.erb</em></p>
  
  <pre><code>&lt;a href="#" id="foo"&gt;link&lt;/a&gt;
  </code></pre>
  
  <p><em>whatishappening/app/assets/javascripts/posts.js</em> (I renamed this from <em>posts.js.coffee</em>)</p>
  
  <pre><code>console.log("posts.js loaded");
  
  $("#foo").on("click", function(event) {
    console.log("link clicked");
  });
  </code></pre>
  
  <p>When I run via <code>rails server</code> and monitor the Javascript console in Chrome, I see:</p>
  
  <pre><code>&gt; posts.js loaded
  </code></pre>
  
  <p>However, I don't see</p>
  
  <p><code>&gt; link clicked</code></p>
  
  <p>when I click the link.</p>
  
  <p>Can someone explain what's happening?</p>