Context
I have a Rails 3 app I'm working on and have the 'jquery-rails' gem installed and
//= require jquery
//= require jquery_ujs
//= require_tree .
in my app/assets/javascripts/application.js file.
Alerts and coffeescript work ok IF they are base level items.
I've put them into app/assets/javascripts/application.js directly, app/assets/javascripts/pages.js and tried it as a coffeescript version in app/assets/javascripts/pages.js.coffee (just changed the file name)
As soon as I put them in something like:
$(document).ready(function(){
alert('works');
});
or (for coffeescript)
jQuery ->
alert "hi"
It will not fire at all.
I've also tried including the jquery file in the application layout but same problems.
Question
Is there a different syntax for declaring jQuery functions within rails? Does anyone have any ideas what could be going wrong?
Any help is appreciated. Thanks!