Skip to content

Instantly share code, notes, and snippets.

@seanlinsley
Last active August 10, 2020 11:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanlinsley/9786622 to your computer and use it in GitHub Desktop.
Save seanlinsley/9786622 to your computer and use it in GitHub Desktop.
# The Active Admin equivalent of putting this in your application layout:
# <head>
# <%= cloudinary_js_config %>
# </head>
module ActiveAdmin
module Views
module Pages
class Base < Arbre::HTML::Document
alias_method :original_build_head, :build_active_admin_head
def build_active_admin_head
original_build_head
within @head do
text_node include_gon
end
end
end
end
end
end
@vasilakisfil
Copy link

I get this error

Started GET "/admin" for 127.0.0.1 at 2014-03-26 17:09:35 +0100
Processing by Admin::DashboardController#index as HTML
  AdminUser Load (2.2ms)  SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = 1 ORDER BY "admin_users"."id" ASC LIMIT 1
  Rendered /home/vasilakisfil/.rvm/gems/ruby-2.1.1/bundler/gems/active_admin-388ed07e477a/app/views/active_admin/page/index.html.arb (22.2ms)
Completed 500 Internal Server Error in 97ms

ActionView::Template::Error (stack level too deep):
  activesupport (4.0.3) lib/active_support/notifications/instrumenter.rb:23


  Rendered /home/vasilakisfil/.rvm/gems/ruby-2.1.1/gems/actionpack-4.0.3/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (16.1ms)

@seanlinsley
Copy link
Author

Just updated the gist to use alias_method instead of super, which appears to work fine

@hoasung01
Copy link

I put it in config/initializers but it still gets error

Uncaught ReferenceError: gon is not defined

@simicic
Copy link

simicic commented Aug 10, 2020

If anyone comes across this, the latest stable version of active_admin uses head instead of @Head.
(https://stackoverflow.com/questions/29488362/how-to-include-gazon-gon-in-activeadmin/59735120#59735120)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment