I have been developing a rails app for a week now. I use jquery-rails gem to use jQuery and everything was working fine. But today, when I started the development server, jQuery just wasn't loading. The console gave the error jQuery not defined and $ not defined and so forth. So I checked if the jQuery files are being included and they were. But when I clicked on the link to the jquery.js file, it contained only the following.

(function() {


jQuery just isnt working..

This is how I have required the js libraries:

//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require bootstrap-datepicker/core
//= require_tree .

I have tried interchanging bootstrap and jQuery and even tried removing jQuery and using only bootstrap. Nothing seems to be working.

The funny part is that it was working perfectly till last night!! And I don't remember adding or removing any js libs. I was only writing Javascript code. So I have no clue as to what went wrong overnight.

The only thing I haven't tried is serving jQuery from a CDN. But that is not an option considering where my app is going to be deployed.

Please help.

My Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.8'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'will_paginate', '~> 3.0.beta'
gem 'will_paginate-bootstrap'

#gem 'sqlite3'
gem 'mysql2'
#gem 'devise'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
    gem 'twitter-bootstrap-rails'
    gem 'less-rails'
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'

gem 'jquery-rails'
gem 'bootstrap-datepicker-rails'
gem 'libv8'

Thanks in advance.

4 Years
Discussion Span
Last Post by LastMitch

Empty body function in jquery.js - Rails 3.2 with jquery-rails gem

Are you connected the jquery files correctly:

You have to used something like this:

<%= javascript_include_tag "application" %>
<%= stylesheet_link_tag "application", :media => "all" %>

and you can add this:


You can read more about it here:


You can also read more about it here (some tips):


Edited by LastMitch: grammer

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.