Активы Activeadmin загружаются на каждой странице без прав администратора - PullRequest
0 голосов
/ 15 июня 2019

У меня проблема с настройкой гема activeadmin.Он работает нормально, но проблема в том, что он загружает ресурсы, необходимые из activeadmin в моем основном представлении макета.Интересно, как заставить его импортировать файлы CSS и JS в представление только при доступе к пути admin .

Заранее спасибо за помощь

  • приложению.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
 */

также существует файл active_admin.scss по тому же пути application.css

1 Ответ

1 голос
/ 15 июня 2019

Директива require_tree в манифесте CSS требует, чтобы все таблицы стилей были из текущего каталога.

Таким образом, вы можете удалить require_tree и включить только те файлы, которые вам нужны.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...