I've upgraded from rails 4.2.6 to rails 5.1, and then started to use webpack.
All set up for using webpack have done, but I can't figure out how to load javascript files on the ActiveAdmin page.
ActiveAdmin loads app/assets/javascripts/active_admin.js.coffee
by default.
Is there a way to load javascript files which is bundled by webpack on the ActiveAdmin page?
I'm a bit late, but I believe it's better to wrap the method rather than to completely override the class. Also, monkey patching Header
will result in tags being rendered in div with id="header"
. In order to render them in <head />
I did the following:
ActiveAdmin::Views::Pages::Base.class_eval do
alias_method :original_build_active_admin_head, :build_active_admin_head
def build_active_admin_head(*args, &block)
original_build_active_admin_head(*args, &block)
within @head do render '/custom_headers' end
end
end
Put this file to config/initializers
(so that it won't be reloaded every time in development mode resulting in infinite loop) folder and create a app/views/_custom_headers.html.erb
file with whatever you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With