Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'
like image 514
NeverBe Avatar asked Jun 20 '26 23:06

NeverBe


1 Answers

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

like image 181
NeverBe Avatar answered Jun 22 '26 12:06

NeverBe