【发布时间】:2019-06-14 21:58:59
【问题描述】:
我在设置activeadmin gem 时遇到问题。它运行良好,但问题是它正在我的主布局视图中从activeadmin 加载所需的资产。我想知道如何使它仅在访问 admin 路径时才将 CSS 和 JS 文件导入视图。
提前感谢您的帮助
- application.html.erb
<!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>
- application.css
/*
* 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
*/
在application.css的同一路径下还有一个active_admin.scss文件
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-5 activeadmin