Asterisks do not load manifest files (jQuery, jQuery_ujs)

I am having the problem of getting asterisks to download the files specified in the manifest section of the file 'application.js'. I tried reordering the directives in the file "application.js", I tried updating and decreasing the sorting of rubies / rails, but nothing forces the asterisks to upload files to the directives.

I added several other files to the "assets / javascripts" and "assets / stylesheets" folders to see if the brackets would be loaded, but not one of them would be loaded. However, if you go into the console and type "Sprockets.class", it will recognize the module, so it seems that the stars actually load.

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 related to asterisks 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 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 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: $ not defined"

When I show the paths of my resources using 'Rails.application.config.assets.paths', I see that the jQuery library is indeed in the download path. I also verified that the files were actually in the location indicated in the path that they are.

I have no dependency messages when trying to link my project, but I suspect this is what is happening. I had many other projects that use the jquery / asset pipeline in Ruby 1.9.2 / Rails 3.2.1, and I did nothing else with my new setup. I understand that stars and jquery are something that should just work out of the box, so I am particularly perplexed.

Thanks!!!!

+4
source share
2 answers

I think this is due to a problem between asterisks and Ruby 2.0. I have the same problem, check: https://github.com/rails/rails/issues/8237 and https://github.com/sstephenson/sprockets/issues/352 . You can just upgrade the rails to 3.2.13, it should work.

+7
source

Is it in a production environment? Try this in your config / environment / production.rb

 config.assets.precompile += ['*.js', '*.css'] 
0
source

Source: https://habr.com/ru/post/1493323/


All Articles