Rails Admin: add javascript library to custom action

I am creating a custom action for the rails admin that includes a custom view. I want to include a local copy of sparkline.js, but I cannot figure out how to do this.

I tried adding sparkline.js to the / vendor / assets / javascripts / actions / action _name directory, but it is not loaded by rails admin

Is there any other way to download this file.

+1
source share
1 answer

I did this by placing the external library in the app / assets / javascripts / rails_admin / custom directory and adding the require statement for the rails_admin ui.js.

i.e.

// in app/assets/javascripts/rails_admin/custom/ui.js //= require ./sparkline.js 

You can also do this with coffeescript:

 # in app/assets/javascripts/rails_admin/custom/ui.js.coffee #= require ./sparkline.js 
+3
source

Source: https://habr.com/ru/post/974158/


All Articles