简体   繁体   中英

ActiveAdmin assets loading in production env

For some reason, some activeadmin's assets (js scripts) can't be loaded for production env.

I have code to initialize the js.

$(document).ready(function () {
    console.log('ready');
    hljs.initHighlightingOnLoad();
});

The problem is that it never starts, but if I register a file with this code, it starts working, but all the required js is not loaded.

#active_admin.js
//= require active_admin/base
//= require highlight_js/highlight
//= require highlight_js/languages/xml
//= require highlight_js/languages/json

#init.js
$(document).ready(function () {
    console.log('ready'); # <- never executes, unless init.js is places to active_admin.rb
    hljs.initHighlightingOnLoad(); # if init.js is places to active_admin.rb then we get an error 'hljs' is unknown object
});

#active_admin.rb
  config.register_javascript 'init.js'

I rearranged require js section and got it worked. But some moments are still mysterious.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM