-->

Javascript files are not included from manifest

2019-06-14 04:05发布

问题:

I am using Ruby On Rails and have ActiveAdmin on top of that on a windows machine. I don´t think ActiveAdmin has anything to do with it, but I am just saying.

The Javascript file that is included via HTML is /assets/active_admin.js and the manifest file itself looks like this:

//= require active_admin/base

//= require just_datetime_picker/nested_form_workaround

When I run my Rails application and open http://localhost:3000/assets/active_admin.js, the log tells me, that active_admin.js was compiled, but the file still looks just like the manifest just with an added semicolon at the end:

//= require active_admin/base

//= require just_datetime_picker/nested_form_workaround
;

Why is no Javascript code included?

When I try to run the precompile pipeline manually via bundle exec rake assets:precompile RAILS_ENV=development, it actually creates all the CSS files, but the JS files still look like the one described above.

Since I am operating on a windows machine, I do not have the gem 'therubyracer' installed, but NodeJS. Also the bundle install works fine and I also do not get any errors.

回答1:

Are you using Ruby v2.0? Try downgrading to 1.9.

Symptom: The JavaScript manifest file does not compile, no errors are shown; however, a mysterious semi-colon ; appears at the end of the file after "preprocessing" the assets.

Solution: Downgrade to Ruby v1.9.3!

See two other posts on the same topic.

  • My Rails Javascript manifest file neither compiles nor include any required files
  • Javascript manifest file "application.js" is not processed

What a sorry mess it is to be programming in 2013!