-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Expected behavior
I expect there to be some way of telling activeadmin-1.1 and activeadmin-2.0 to include a third-party .css-file.
Actual behavior
In activeadmin-1.0, you have two ways to get this to work.
- With an
@import 'select2'
-statement in app/assets/stylesheets/active_admin.scss. - With an
config.register_stylesheet 'select2.css'
-statement in config/initializers/active_admin.rb.
In activeadmin-1.1, an @import
-statement that refers to a .css-file no longer works, because activeadmin switched from sass-rails
to sass
. Trying this anyway results in an error.
Sass::SyntaxError in ActiveAdmin::Devise::Sessions#new
Showing /usr/local/lib/ruby/gems/2.2.0/gems/activeadmin-1.1.0/app/views/layouts/active_admin_logged_out.html.erb where line #9 raised:
File to import not found or unreadable: select2.
Load paths:
/mnt/c/projects/my-project/app/assets/config
/mnt/c/projects/my-project/app/assets/images
/mnt/c/projects/my-project/app/assets/javascripts
/mnt/c/projects/my-project/app/assets/stylesheets
/mnt/c/projects/my-project/vendor/assets/javascripts
/mnt/c/projects/my-project/vendor/assets/stylesheets
/usr/local/lib/ruby/gems/2.2.0/gems/xdan-datetimepicker-rails-2.5.4/app/assets/javascripts
/usr/local/lib/ruby/gems/2.2.0/gems/xdan-datetimepicker-rails-2.5.4/app/assets/stylesheets
/usr/local/lib/ruby/gems/2.2.0/gems/select2-rails-4.0.3/vendor/assets/javascripts
/usr/local/lib/ruby/gems/2.2.0/gems/select2-rails-4.0.3/vendor/assets/stylesheets
/mnt/c/projects/activeadmin_addons/app/assets/images
/mnt/c/projects/activeadmin_addons/app/assets/javascripts
/mnt/c/projects/activeadmin_addons/app/assets/stylesheets
/mnt/c/projects/activeadmin_addons/vendor/assets/jquery_palette_color_picker
/usr/local/lib/ruby/gems/2.2.0/gems/activeadmin-1.1.0/app/assets/images
/usr/local/lib/ruby/gems/2.2.0/gems/activeadmin-1.1.0/app/assets/javascripts
/usr/local/lib/ruby/gems/2.2.0/gems/activeadmin-1.1.0/app/assets/stylesheets
/usr/local/lib/ruby/gems/2.2.0/gems/activeadmin-1.1.0/vendor/assets/javascripts
/usr/local/lib/ruby/gems/2.2.0/gems/activeadmin-1.1.0/vendor/assets/stylesheets
/usr/local/lib/ruby/gems/2.2.0/gems/coffee-rails-4.2.2/lib/assets/javascripts
/usr/local/lib/ruby/gems/2.2.0/gems/formtastic-3.1.5/app/assets/stylesheets
/usr/local/lib/ruby/gems/2.2.0/gems/jquery-rails-4.3.1/vendor/assets/javascripts
/usr/local/lib/ruby/gems/2.2.0/gems/actioncable-5.0.6/lib/assets/compiled
/usr/local/lib/ruby/gems/2.2.0/gems/turbolinks-source-5.0.3/lib/assets/javascripts
Extracted source (around line #1):
@import 'select2';
@import 'jquery.xdan.datetimepicker';
@import 'palette-color-picker';
@import 'inputs/numeric-range-filter';
@import 'inputs/color-picker';
Rails.root: /mnt/c/projects/my-project
Application Trace | Framework Trace | Full Trace
/mnt/c/projects/activeadmin_addons/app/assets/stylesheets/activeadmin_addons/all.scss:1
sass (3.5.2) lib/sass/tree/import_node.rb:67:in `rescue in import'
In activeadmin-1.1, register_stylesheet
still works, but raises a deprecation warning.
DEPRECATION WARNING: Active Admin: The `register_stylesheet` config is deprecated and will be removed
in v2. Import your "select2.css" stylesheet in the active_admin.scss.
(called from block in <top (required)> at /mnt/c/projects/my-project/config/initializers/active_admin.rb:5)
In activeadmin-2.0, register_stylesheet
was removed, so there is no longer a way to include a third-party .css-file.
How to reproduce
- Create a new Active Admin-app.
- Remove
sass-rails
from the Gemfile (it's supposed to be optional). - Attempt to include some third-party .css-file in Active Admin, such as https://github.com/argerim/select2-rails/blob/master/vendor/assets/stylesheets/select2.css.
Available workarounds
Add gem 'sass-rails'
to the Gemfile of your Active Admin-app.
Solution
Re-add 'sass-rails' as an explicit dependency of activeadmin.
https://github.com/activeadmin/activeadmin/pull/5037/files#diff-e7529ad2dc91228fecef674a9b3dffbb
See also
https://github.com/activeadmin/activeadmin/blob/master/CHANGELOG.md#110-
platanus/activeadmin_addons#156
https://github.com/activeadmin/activeadmin/blob/1-1-stable/lib/active_admin/asset_registration.rb
https://stackoverflow.com/questions/27170575/activeadmin-and-additional-custom-css-files