阻止在非active_admin页面上加载活动管理资源

时间:2017-02-26 05:45:21

标签: ruby-on-rails asset-pipeline activeadmin ruby-on-rails-5

使用active_admin并且效果很好。 Active admin有很多依赖项,例如jquery-ui, datepicker etc..

<script src="/assets/active_admin/jquery_ui.self-75a11da44c802486bc6f65640aa48a730f0f684c5c07a42ba3cd1735eb3fb070.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/base.self-ab2cb3098b53fe7d229937d768d701e8f4013f2a5aea7988d8f2149fa40426db.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/lib/batch_actions.self-fbed82dc1e31cf860056cce6c02f5bc5831ad5343d68ac3ab17471c9e05e9195.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/lib/checkbox-toggler.self-ab6f686db7db58fd7f370cd6f7a6d7abe6884b8d2a144f42a744c2276587b457.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/lib/dropdown-menu.self-8ccb356121a1c40094bb429d6cfac85d9c8ad114fb93730892d9df9986730a0a.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/lib/flash.self-8f05a5d9328ea28fca100b057787fbfb567986513c5f1735ea48fad8f9571c10.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/lib/has_many.self-ece319debdc01ca5096ae8ac6c130ffc0decab382543b4b94e18591375d3d3bb.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/lib/modal_dialog.self-5dfc6e87bae26cd4a021eb86951d3691ed07e6d2bf242a8eb65dc6965e12096c.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/lib/per_page.self-94323c49402595a22bdea01b8dc3f8103e290d300238ebd49efa26d76d7ee117.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/lib/table-checkbox-toggler.self-f5200d732ec9ffd4ee8fd1fe11524ad7b54a67f6c0ef447a29d119ece2dcecdb.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/ext/jquery-ui.self-f96f2ec2a32c4bc4da4292cc74bddeca0bb223d81a421c98c4d613632860945e.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/ext/jquery.self-da8dafbbe883092bcae73f35a8caf4ae6170fe7d8130ae7039a233f9b509c757.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/initializers/batch_actions.self-f5c360e8640b40f00640f6e5c7cfe0addeb244ed72e1a9828c52919515d23cf1.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/initializers/datepicker.self-f8ac66c85afd35ee1555c09a2418efc7a7930e1f6dd783461379c2bb2184f80e.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/initializers/filters.self-9b9312d6bed532db668c5417a009b7fb7caf58f33299783ed02c2c72340a498a.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin/initializers/tabs.self-65de8b1688d4f8782c04bf07ba6314d3c8b33b9391a482a07214ac4df99dd904.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/active_admin.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" data-turbolinks-track="reload"></script>

我没有在我的应用中的任何其他部分使用这些。但我可以看到无论是否有活动的管理页面,它都会加载。那么是否可以仅为活动管理页面加载这些资源? (如果不可能,可以从asset pipeline删除活动管理员,以便依赖关系不会加载到other app parts)?

2 个答案:

答案 0 :(得分:1)

你能删除吗?  来自#define LINE_MAX_CHARS 1000 // n = number of strings to be found // **strings = array of strings to look for in file void count_occurrences (int n, FILE *file, char **strings) { char str[LINE_MAX_CHARS]; // buffer int count = 0; while (fgets(str, LINE_MAX_CHARS, file) != NULL){ // for each line for (int i = 0; i < n; i++){ // for each word in line char *found = str; do { found = strstr(found, strings[i]); // search line if (found != NULL){ // if word found in line count = count + 1; found++; } } while (found) } } } 的{​​{1}} 再试一次?

答案 1 :(得分:1)

类似于Fivell的答案。我在required_tree .之后通过stub对其进行了修复,以避免在active_admin.js中需要application.js

所以app/assets/javascripts/application.js会变成:

// This is a manifest file that'll ...
// ...
//= require rails-ujs
//= require activestorage
//= require_tree .
//= stub active_admin

就我而言(Rails 5.2.3和ActiveAdmin 2.1.0),更改此设置不会阻止ActiveAdmin加载active_admin.cssactive_admin.js,因此管理页面应该没问题。