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