I use active admin and in my app there are different .js that must be loaded in specifics pages (not all).
Following this topic Best way to add page specific javascript in a Rails 3 app? it appears to be easy, but the layout in active admin is compiled.
I have used a workaround to overwrite the footer:
class ActiveAdmin::Views::Pages::Base < Arbre::HTML::Document
private
# Renders the content for the footer
def build_footer
div :id => "footer" do
para "Copyright © #{Date.today.year.to_s}- All rights reserved ".html_safe
end
end
end
How can I add some .js in the header of some pages? How with a workaround? (if possible with a "yield :head" or something like that, so I can call it easier from everywhere ;))
EDIT NOTE: the js that i want to include render a highcharts
I'm using master branch of ActiveAdmin 0.5.0 (as of 23 Nov 2012) and there is a Arbre builder method within
which is working for me.
show do
within @head do
script :src => javascript_path('somefile.js'), :type => "text/javascript"
end
end
You can see an example of its use in ActiveAdmin::Views::Pages::Base#build_active_admin_head
.
Hope this helps.