Tôi muốn thêm Gòn (https://github.com/gazay/gon) để activeadmin tôitích cực quản trị: Bao gồm Javascript
nhưng tôi cần phải thêm dòng
<%= include_gon %>
vào phần đầu trong việc bố trí
nhưng tôi không thể hiểu được làm thế nào?
Tôi muốn thêm Gòn (https://github.com/gazay/gon) để activeadmin tôitích cực quản trị: Bao gồm Javascript
nhưng tôi cần phải thêm dòng
<%= include_gon %>
vào phần đầu trong việc bố trí
nhưng tôi không thể hiểu được làm thế nào?
Để thêm vào nhận xét của Mexxer. Tới `config/initializers/active_admin.rb
Ở dưới cùng của trang, bạn sẽ tìm thấy những điều sau đây:
# == 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'
Bỏ ghi chú dòng cuối cùng và thay thế my_javascript.js với tập tin của bạn, như thế này ...
# To load a javascript file:
config.register_javascript 'invoices.js'
Đó tập tin có thể được đặt tại app/assets/javascripts/invoices.js
này cũng có thể có liên quan:
# 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
Rails.application.config.after_initialize do
javascripts = []
javascripts << "//maps.googleapis.com/maps/api/js?sensor=false&key="
javascripts += ActiveAdmin.application.javascripts.to_a
ActiveAdmin.application.javascripts.replace javascripts
end
https://github.com/activeadmin/activeadmin/issues/340#issuecomment-92512556