Reputation: 2796
For some reason, after running rake assets:precompile
, require
statements in application.js
are left untouched. Here is how compiled application.js
looks like:
//
//= require jquery
//= require jquery_ujs
//= require_directory .
//= require twitter/bootstrap
//= require rails.validations
$(document).on("click", '.show', function(e) {
var value = $(this).attr('data-big-url');
$('.image_container img').attr('src', value);
return false;
});
That //= require
statements should be substituted!
Any ideas?..
THanks!
EDIT: uncompiled 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_directory .
//= require twitter/bootstrap
//= require rails.validations
$(document).on("click", '.show', function(e) {
var value = $(this).attr('data-big-url');
$('.image_container img').attr('src', value);
return false;
});
// $(window).load(function() {
// $('#featured').orbit();
// // $('#featured-bg').orbit();
...
It looks exactly the same!
Here is my production.rb
:
config.serve_static_assets = true
config.assets.compress = false
config.assets.compile = false
config.assets.digest = false
Upvotes: 0
Views: 131
Reputation: 2796
Finally, I solve the issue:
I had to downgrade to Ruby 1.9.3.
Unfortunately, I still don't know what was the reason of the issue, but now I have my assets compiling correctly.
Upvotes: 0
Reputation: 76774
I may be wrong, but I don't believe you'd want require ____
in a precompiled JS file
The reason is the
require
lines are called directives which guide the creation of amanifest.json
file for your assets. The manifest basically tells Rails which files make up your assets, allowing it to compile them effectively
You can see the precompiling documenation from the Rails guide here - basically says that the files you get from precompilation are "standalone" files. They are meant to be loaded as static files, without any preprocessors or directives
I would try this:
$ rake assets:precompile RAILS_ENV=production
This will compile the files as if it were the production environment, and storing them in /public/assets
as a naked JS / CSS file
Upvotes: 1