I am having an issue getting sprockets to load the files specified in the manifest section of 'application.js' file. I have tried re-ordering the directives in the 'application.js' file, I have tried upgrading and down-grading ruby/rails but nothing is causing sprockets to load the files in the directives.
I added a few other files into the 'assets/javascripts' and 'assets/stylesheets' folders to see if sprockets would load those but none of those are getting loaded either. However, if drop into the console and type 'Sprockets.class' it recognizes the module so it seems that sprockets is indeed being loaded.
I am using Ruby 2.0.0/Rails 3.2.8
Here is 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 'sqlite3'
gem "rspec-rails", :group => [:test, :development]
group :test do
gem "factory_girl_rails"
gem "capybara"
gem "guard-rspec"
gem "debugger"
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem "jquery-rails"
And here is my Gemfile.lock with any entry relating to sprockets or jQuery
specs:
actionpack (3.2.1)
sprockets (~> 2.1.2
sprockets (2.1.3)
jquery-rails (3.0.4)
DEPENDENCIES
jquery-rails
EDIT 1 -- Application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require jquery.cookie
//= require_tree .
$(document).ready(function(){
alert('shit is ready');
});
Then in the chrome console I get 'Uncaught ReferenceError: $ is not defined'
When I display my asset paths using 'Rails.application.config.assets.paths' I can see that the jQuery library is indeed in the load path. I have also checked to make sure that the files are actually at the location specified in the path, which they are.
I have not gotten any sort of dependency messages when trying to bundle my project but I suspect that that is what is going on. I was have plenty of other projects that use jquery/asset pipeline in Ruby 1.9.2/Rails 3.2.1 and I have not done anything different with my new set up. My understanding is that sprockets and jquery are both things that should just work out of the box so I am especially perplexed.
Thanks!!!!
I think this is because of issue between sprockets and Ruby 2.0. I got the same issue, check out: https://github.com/rails/rails/issues/8237 and https://github.com/sstephenson/sprockets/issues/352. You can just update rails to 3.2.13, it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With