我在设置activeadmin
gem时遇到问题。运行正常,但问题是它正在从activeadmin
的主布局视图中加载所需的资产。我想知道如何仅在访问 admin 路径时将CSS和JS文件导入视图。
在此先感谢您的帮助
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= render "shared/main_nav" %>
<%= yield %>
</body>
</html>
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
在active_admin.scss
的同一路径中还有一个application.css
文件
答案 0 :(得分:1)
CSS清单中的require_tree指令要求当前目录中的所有样式表。
因此,您可以删除require_tree并仅包含所需的文件。