The rails asset pipeline isn't including files required in application.js.
The only javascript file rendered to the browser is application.js, and the require lines are not compiled to include tags as they should be:
// 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 twitter/bootstrap
//= require bootstrap
//= require_tree .
;
in config/application.rb I have config.assets.enable = true
I'm using rails 3.2.8, and I've tried ruby 1.9.3-p398 and 2.0.0-p0 installed using rvm.
How do I get application.js to include the files required?
EDIT: It looks like the lock on this question was recently unlocked, and activity has increased. It has been a while since I worked on this, and the code doesn't exist anymore. If I am remembering correctly I reinstalled ruby and rails and that fixed the problem.
Should I close this question? What is the proper procedure in this situation?
I answered this here:
Rails 3.2.8 Application.js and Application.css are not working as expcted
Here's the text:
I was also having this issue but with newer versions of Rails and Ruby.
Examining the log, I was being served javascript.js from Rails cache as the server didn't see a change in the file. I went and moved the require lines around (just one) to tell Rails that there's a change in the file and re-compile/use. Wellm that did it for me!
Hope it helps somebody.
Another important finding is to upgrade your sprockets gem in your Gemfile.
I had version 2.2.1 and had issues, after upgrading to 2.2.2, it worked
gem 'sprockets', '2.2.2'
If you are upgrading from 3.0.x - 3.1.x and run in to this issue upgrade to 3.2.x and It may solve this issue.
I recently upgraded an app from 3.0 - 3.1.12 and found the asset manifest would not work using Ruby 1.9.3, Ruby 2.0, or Ruby 2.1.1. I then went ahead and upgraded to 3.2.17 and everything seems to be working correctly using Ruby 2.1.1.
Hopefully this helps anyone else that may run in to this issue upgrading.
One common reason for this is that the assets are compiled and found in public/assets, in which case Rails will not recompile them. If you have assets in here, and have not set config.serve_static_assets to false, then Rails will not recompile your assets:
config.serve_static_assets = false
So if you have precompiled stuff in public/assets, either delete them, or add the above line to development.rb
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