Search code examples
ruby-on-railslayoutactiveadmin

Active Admin: Including Javascript


I want to add Gon ( https://github.com/gazay/gon ) to my activeadmin

but I need to add the line

<%= include_gon %>

to the head section in the layout

but I can't figure out how?


Solution

  • To add to Mexxer's comment. Go to `config/initializers/active_admin.rb

    At the bottom of the page, you'll find the following:

    # == Register Stylesheets & Javascripts
    #
    # We recommend using the built in Active Admin layout and loading
    # up your own stylesheets / javascripts to customize the look
    # and feel.
    #
    # To load a stylesheet:
    #   config.register_stylesheet 'my_stylesheet.css'
    #
    # To load a javascript file:
    #   config.register_javascript 'my_javascript.js'
    

    Uncomment the last line and replace my_javascript.js with your file, like this...

    # To load a javascript file:
    config.register_javascript 'invoices.js'
    

    That file can be located at app/assets/javascripts/invoices.js